private void RefreshUI() { lblCurrentHP1.Text = redis.GetHP(true).ToString(); lblCurrentHP2.Text = redis.GetHP(false).ToString(); lblCurrentResource1.Text = redis.GetResource(true).ToString(); lblCurrentResource2.Text = redis.GetResource(false).ToString(); lblAction.Text = redis.GetAction().ToString(); txtCombatLog.Text = redis.GetCombatLog(); txtCombatLog.SelectionStart = txtCombatLog.Text.Length; txtCombatLog.ScrollToCaret(); if (redis.GetAction() == 0) { btnPrimary1.Enabled = false; btnPrimary2.Enabled = false; } if (redis.GetTurn()) // Player 1s turn { if (redis.GetResource(true) == 0) { btnSecondary1.Enabled = false; } else { btnSecondary1.Enabled = true; } } else // Player 2s turn { if (redis.GetResource(false) == 0) { btnSecondary2.Enabled = false; } else { btnSecondary2.Enabled = true; } } }
public Arena(Character player1, Character player2) { InitializeComponent(); redis = new RedisManager(); redis.MatchOver(); // Flushing DB in case of leftover values // Names lblPlayer1.Text = player1.Title; lblPlayer2.Text = player2.Title; // Pictures picPlayer1.Image = player1.Picture; picPlayer2.Image = player2.Picture; // Characters this.player1 = player1; this.player2 = player2; // Character Classes player1Class = new CharacterClass(player1); player2Class = new CharacterClass(player2); // Max Health lblMaxHP1.Text = player1Class.MaxHealth.ToString(); lblMaxHP2.Text = player2Class.MaxHealth.ToString(); // Max Resources lblMaxResource1.Text = player1Class.MaxResource.ToString(); lblMaxResource2.Text = player2Class.MaxResource.ToString(); // Armor Class lblAC1.Text = player1Class.ArmorClass.ToString(); lblAC2.Text = player2Class.ArmorClass.ToString(); // Ability Names btnPrimary1.Text = player1Class.PrimaryName; btnPrimary2.Text = player2Class.PrimaryName; btnSecondary1.Text = player1Class.SecondaryName; btnSecondary2.Text = player2Class.SecondaryName; // Match Start redis.MatchStart(player1Class, player2Class); // Roll Initiative if (player1Class.RollDie(20) >= player2Class.RollDie(20)) { redis.SetTurn(true); redis.AddToCombatLog("Player 1 plays first."); lblTurn.Text = "<< Player 1's turn."; //btnPrimary1.Enabled = true; //btnSecondary1.Enabled = true; btnPrimary2.Enabled = false; btnSecondary2.Enabled = false; } else { redis.SetTurn(false); redis.AddToCombatLog("Player 2 plays first."); lblTurn.Text = "Player 2's turn. >>"; btnPrimary1.Enabled = false; btnSecondary1.Enabled = false; //btnPrimary2.Enabled = true; //btnSecondary2.Enabled = true; } // Combat Log txtCombatLog.Text = redis.GetCombatLog(); // Action lblAction.Text = redis.GetAction().ToString(); // Current Health lblCurrentHP1.Text = redis.GetHP(true).ToString(); lblCurrentHP2.Text = redis.GetHP(false).ToString(); // Current Resource lblCurrentResource1.Text = redis.GetResource(true).ToString(); lblCurrentResource2.Text = redis.GetResource(false).ToString(); }