msg.setPlayer(client.getPlayer());
client.send(msg);
}
else //otherwise, fired by SuggestionView and it contains an actual theory
{
this.fireTextStatusEvent(new TextStatusEvent(this, theory.getTheoryText()));
if(isServer)
{
//Inject player as theorist if null
if(theory.getTheorist() == null)
theory = new Theory(Theory.Type.SUGGESTION, theory.getWeapon(), theory.getCharacter(), theory.getLocation(), this.currentPlayer); //this.client.getPlayer());
//TODO: Shouldn't this only check the immediately next player, unless they have none of the cards in question?
for(Player player : this.game.getPlayers())
{
if(!player.equals(currentPlayer))
{
Vector<Card> hand = player.getHand();
LinkedList<Card> invalidCards = new LinkedList<Card>();
for(Card card : hand){
switch(card.getCardType()){
case WEAPON_CARD:
if(theory.getWeapon().getWeaponType().equals(((WeaponCard)card).getWeaponType())){
invalidCards.add(card);
}
break;
case CHARACTER_CARD:
if(theory.getCharacter().getCharacterName().equals(((CharacterCard)card).getCharacterName())){
invalidCards.add(card);
}
break;
case LOCATION_CARD:
if(theory.getLocation().getRoomName().equals(((LocationCard)card).getLocationName())){
invalidCards.add(card);
}
break;
}
}
if(invalidCards != null){
if(invalidCards.size()==1) {
// This player has one of the suggestion cards, notify the suggester AND let everyone else know at least one card in the suggestion is wrong.
server.send(theory.getTheorist(), new SuggestionDisprovedCardMessage(player, invalidCards.get(0)));
server.sendAll(new SuggestionDisprovedMessage(player, theory));
return;
} else if(invalidCards.size()>1) {
// This player has more than one card - we need them to decide which one to show the suggester.
this.fireSuggestionDisprovedNeedFeedBackEvent(new SuggestionDisprovedNeedFeedBackEvent(this, theory, invalidCards));
server.sendAll(new SuggestionDisprovedMessage(player, theory));
server.send(player, new SuggestionDisprovedNeedFeedBackMessage(theory, invalidCards));
return; //If we hit 1 result, it moves to the next player's turn. Not all cards in the suggestion get proved.
}
fireTextStatusEvent(new TextStatusEvent(this, "Theory disproven."));
}
}
}
}
else