/// <summary> /// Select the card to attack /// </summary> /// <typeparam name="Element"></typeparam> /// <param name="active">The active player's compounds</param> /// <param name="cPlayer">The array position fo the current player (not directly used, parameter only)</param> private void selectCard <Element>(List <Compound> activeHand, int cPlayer) { turnPos = TurnPos.attackActive; selectedString = " "; while (selectedString != "") { selectedString = Console.ReadLine(); for (int i = 0; i < player[cPlayer].Compounds.Count; i++) { try { selected = Convert.ToInt16(selectedString); go = true; } catch (Exception) { go = false; } if (go) { if (selected == i + 1 && player[cPlayer].Compounds[i].elementnum * 2 <= player[cPlayer].Energy) { attack(cPlayer); } else if (selected == -(i + 1) && player[cPlayer].Compounds[i].elementnum * 2 <= player[cPlayer].Energy) { defend(-selected); } } } } turnPos = TurnPos.other; }
public Field() { player = new Player[2] { new Player(), new Player() }; turnCount = 0; turnPos = TurnPos.other; }
/// <summary> /// Run a player's turn /// </summary> /// <param name="active">The active player</param> public void turn() { if (turnPosB == 1 && isWon() == 0) { turnCount = turnCount + 1; active = turnCount % 2; turnPosB++; } if (turnPosB == 2 && isWon() == 0) { player[active].income(); turnPosB++; ConsoleDraw(); } if (turnPosB == 3 && isWon() == 0) { selectCard <Element>(player[active].Compounds, active); turnPosB++; } if (turnPosB == 4 && isWon() == 0) { turnPos = TurnPos.crafting; turnPosB++; } if (turnPosB == 5 && isWon() == 0) { //turnPosB = 0; player[active].useCrucible(); } if (turnPosB == 6 && isWon() == 0) { player[active].DrawCards(turnCount / 2 - turnCount % 2); turnPosB = 1; } ConsoleDraw(); }