Example #1
0
 public void OnTurnEnd(TurnEnd turn)
 {
     if (IsWriteLog)
     {
         Console.WriteLine("[IPC] Receive TurnEnd");
     }
     Canceller?.Cancel();
 }
Example #2
0
        private IResponse TryTurnEnd(TurnEnd turnEnd)
        {
            Assert.IsNotNull(turnEnd);
            if (turnEnd.Player != CurrentPlayer.Value)
            {
                Warn($"It's not {turnEnd.Player}'s turn to end");
                return(Response.Ok);
            }

            EndTurn();

            return(Response.Ok);
        }
Example #3
0
 public void NextTurn()
 {
     if (TurnEnd != null)
     {
         TurnEnd.Invoke();
     }
     turn++;
     Debug.Log(turnPlayer);
     if (TurnStart != null)
     {
         TurnStart.Invoke();
     }
     turnPlayer.Turn();
 }
Example #4
0
        private IResponse TryTurnEnd(TurnEnd turnEnd)
        {
            Assert.IsNotNull(turnEnd);
            var player = turnEnd.Owner as IPlayerModel;

            if (turnEnd.Player != CurrentPlayer.Value)
            {
                Warn($"Arbitrate: It's not {turnEnd.Player}'s turn to end.");
                return(new Response(turnEnd, EResponse.Fail, EError.Error, "Not {turnEnd.Players}'s turn to end."));
            }

            if (IsInCheck(player))
            {
                var b = IsInCheck(player);
                Warn($"Arbitrate: {turnEnd} leaves {player}'s king in check, failing.");
                return(new Response(turnEnd, EResponse.Fail, EError.Error, "Can't leave King in Check"));
            }

            EndTurn();
            return(Response.Ok);
        }
Example #5
0
 private void OnEnable()
 {
     s_OnTurnEnd += FinishTurn;
 }
Example #6
0
 private void OnDisable()
 {
     s_OnTurnEnd -= FinishTurn;
 }
 public void EndTurn()
 {
     TurnEnd?.Invoke();
 }
Example #8
0
 void MoveToNextPhase()
 {
     nextPhase = new TurnEnd(battleManager, playerStats, npcData, playerHand, npcHand, isChallengeWon);
     stage     = Stages.Exit;
 }
Example #9
0
        public override void Update()
        {
            // Pre-battle

            ShowText("Beginning battle between " + battlers[0].Name + " and " + battlers[1].Name + ". ");
            foreach (Battler b in battlers)
            {
                if (!(b is Player))
                {
                    NPC n = (NPC)b;
                    ShowText(n.Name + ": " + n.Text[0]);
                }
            }

            // Main battle loop
            while (battlers[0].Mana > 0 && battlers[1].Mana > 0)
            {
                // Main turn loop
                foreach (Battler b in battlers)
                {
                    // Pre-turn
                    cursorLocation[0] = 2;
                    cursorLocation[1] = 0;
                    if (b.Mana <= 0)
                    {
                        break;
                    }
                    if (b.Mana > b.MaxManaAllotment)
                    {
                        b.Mana         -= b.MaxManaAllotment;
                        b.ManaAllotment = b.MaxManaAllotment;
                    }
                    else
                    {
                        b.ManaAllotment = b.Mana - 1;
                        b.Mana          = 1;
                    }
                    ShowText(b.Name + "'s turn.", !(b is NPC));
                    b.HasMoved = false;
                    if (b.PlayDeck.Count > 0)
                    {
                        if ((turn > 0 || Array.IndexOf(battlers, b) > 0) && b.Hand.Count < 9)
                        {
                            b.Draw();
                        }
                    }
                    else
                    {
                        b.Mana -= b.MaxManaAllotment;
                        ShowText(b.Name + "'s deck is empty! " + b.Name + " takes " + b.MaxManaAllotment + " damage as punishment!");
                        if (b.Mana <= 0)
                        {
                            break;
                        }
                    }

                    for (int i = 0; i < b.Field.Length; i++)
                    {
                        if (b.Field.Monsters[i] != null)
                        {
                            ((Monster)b.Field.Monsters[i]).CanAttack = true;
                        }
                    }

                    TurnStart?.Invoke(this, new BattleEventArgs(b, GetOpponent(b)));

                    // Turn processing
                    if (b is NPC)
                    {
                        AITurn(b);
                    }
                    else if (b is Player)
                    {
                        UpdateSprites();
                        PlayerTurn(b);
                    }

                    // End of turn
                    UpdateSprites("End of " + b.Name + "'s turn.");

                    if (!b.HasMoved && b.MaxManaAllotment < 10)
                    {
                        b.MaxManaAllotment += 2;
                        if (b.MaxManaAllotment > 10)
                        {
                            b.MaxManaAllotment = 10;
                        }
                        ShowText(b.Name + " forfeited their turn to boost Mana consumption. Max Mana allotment for next turn is " + b.MaxManaAllotment + ".");
                    }

                    TurnEnd?.Invoke(this, new BattleEventArgs(b, GetOpponent(b)));

                    if (b.ManaAllotment > 0)
                    {
                        b.Mana += b.ManaAllotment;
                    }
                    else
                    {
                        b.MaxManaAllotment++;
                    }
                    b.ManaAllotment = 0;
                    turn++;
                }
            }

            //End battle
            //TODO: Tie handling
            if (battlers[0].Mana <= 0)
            {
                winner = battlers[1];
            }
            else if (battlers[1].Mana <= 0)
            {
                winner = battlers[0];
            }
            ShowText(winner.Name + " wins!");

            if (winner is Player)
            {
                PlayerVictory();
            }
            else
            {
                PlayerLoss();
            }
            UpdateSprites();
            EndScene();
        }
Example #10
0
	public void ResetTurn() {
		if(this.totalScore.totalTurns == 0) {
			Game.Instance.FirstTurn();
		}

		this.totalScore.totalActionsPerformed += this.turnInfo.numActionsPerformed;
		this.totalScore.totalActionsExpected += this.turnInfo.numActionsExpected;
		++this.totalScore.totalTurns;

		this.currentRatio = 0.0f;
		this.turnEnd = new TurnEnd();

		this.turnInfo.numActionsExpected = Difficulty.NumActionsTurn(this.totalScore.totalTurns);
		this.turnInfo.timeExpected = Difficulty.SecondsInTurn(this.turnInfo.numActionsExpected,
				this.totalScore.totalTurns);
	
		this.turnInfo.numActionsPerformed = 0;
		this.turnInfo.timePerformed = 0.0f;
		this.turnInfo.currentIdx = 0;

		this.turnInfo.buttons.Clear();
	}
Example #11
0
 public void NextTurn()
 {
     TurnStart?.Invoke();
     Turn++;
     TurnEnd?.Invoke();
 }
Example #12
0
 private void Awake()
 {
     Instance = this;
 }
Example #13
0
 protected MockModelPlayerBase(EColor color)
     : base(color)
 {
     _Pass    = new Pass(this);
     _EndTurn = new TurnEnd(this);
 }