public override void fieldLogic(MouseState mouseState, FunctionalRow row, Card card, BoardFunctionality boardFunc) { if (clickedInCardBox) { if (!row.isWithinModifiedPosition(mouseState, card)) { if (selectAction.TargetEnemyCard(mouseState, boardFunc, false) != null) { MouseTransformer.Set(MouseTransformer.State.Reg); if (selectAction.TargetEnemyCard(mouseState, boardFunc, false).correctRow(boardFunc.enemySide).revealed) { switch (selectAction.TargetEnemyCard(mouseState, boardFunc, false).correctRow(boardFunc.enemySide).type) { case CardType.FieldUnit: boardFunc.Fight(card, selectAction.TargetEnemyCard(mouseState, boardFunc, false)); break; case CardType.Army: if (boardFunc.enemySide.Rows[Side.FieldUnit].isEmpty()) { boardFunc.Fight(card, selectAction.TargetEnemyCard(mouseState, boardFunc, false)); } else if (!boardFunc.enemySide.Rows[Side.FieldUnit].isEmpty()) { boardFunc.BOARDMESSAGE.addMessage("Cannot fight an Army if a FieldUnit is present on the board!"); } break; case CardType.General: boardFunc.BOARDMESSAGE.addMessage("A FieldUnit cannot target a General!"); break; } } } else { MouseTransformer.Set(MouseTransformer.State.Atk); resetIfNoSelection(mouseState, row, card, boardFunc); } } if (mouseState.LeftButton == ButtonState.Released && boardFunc.enemySide.Life.isWithinBox(mouseState)) { if (boardFunc.enemySide.Rows[Side.FieldUnit].isEmpty() && boardFunc.enemySide.Rows[Side.Armies].isEmpty() && boardFunc.enemySide.Rows[Side.Armies].revealed) { boardFunc.LifeDamage(card); } else { boardFunc.BOARDMESSAGE.addMessage("---> or Fog"); boardFunc.BOARDMESSAGE.addMessage("---> an Enemy Army"); boardFunc.BOARDMESSAGE.addMessage("---> an Enemy FieldUnit"); boardFunc.BOARDMESSAGE.addMessage("Cannot deal damage to a player if there's:"); } resetIfNoSelection(mouseState, row, card, boardFunc); } resetIfNoSelection(mouseState, row, card, boardFunc); } }
public void VERYBASICATTACKLOGIC(BoardFunctionality boardFunc) { foreach (Card card in boardFunc.friendlySide.Rows[Side.FieldUnit].cardsInContainer) { foreach (Card enemyCard in boardFunc.enemySide.Rows[Side.FieldUnit].cardsInContainer) { if (!card.cardProps.exhausted) { if (enemyCard.cardProps.defense - card.cardProps.power <= 0) { card.cardProps.exhausted = true; boardFunc.Fight(card, enemyCard); } else if (card.cardProps.defense - enemyCard.cardProps.power > 0) { card.cardProps.exhausted = true; boardFunc.Fight(card, enemyCard); } } } } }
public void SetPlays(BoardFunctionality boardFunc) { int counter = 0; foreach (Card card in enemyCards) { Play newPlay = new Play(); Func <int> testAction = () => { int value = 0; if (card.cardProps.aiCalcDefense > 0) { card.cardProps.aiCalcDefense -= OPERATOR.cardProps.power; OPERATOR.cardProps.aiCalcDefense -= card.cardProps.power; if (card.cardProps.aiCalcDefense <= 0) { value += getValue(card) + 1; } if (OPERATOR.cardProps.aiCalcDefense <= 0) { value -= getValue(OPERATOR); } } else { card.cardProps.aiCalcDefense -= OPERATOR.cardProps.power; OPERATOR.cardProps.aiCalcDefense -= card.cardProps.power; if (OPERATOR.cardProps.aiCalcDefense <= 0) { value -= getValue(OPERATOR); } } return(value); }; Action realAction = () => { boardFunc.Fight(OPERATOR, card); }; Action resetAction = () => { card.cardProps.aiCalcDefense = card.cardProps.defense; OPERATOR.cardProps.aiCalcDefense = OPERATOR.cardProps.defense; }; newPlay.testPlay = testAction; newPlay.realPlay = realAction; newPlay.resetValues = resetAction; play.Add(counter, newPlay); counter++; } Play nothingPlay = new Play(); Action nothingAction = () => { }; Func <int> nothingReturn = () => { return(0); }; nothingPlay.realPlay = nothingAction; nothingPlay.testPlay = nothingReturn; nothingPlay.resetValues = nothingAction; play.Add(counter, nothingPlay); counter++; maxPlays = counter; }