public void RobotDrawingACard(Robot robot) { //Drawing a passive card if (robot.CurrentPosition == 5 || robot.CurrentPosition == 15 || robot.CurrentPosition == 25 || robot.CurrentPosition == 35) { PassiveCard passiveCardForm = new PassiveCard(m_BoardGameForm.CurrentTurn, player, robot1, robot2, robot3, m_GameHandler.cards); if (passiveCardForm.ShowDialog() == DialogResult.OK) { if (!passiveCardForm.NoPassiveCard) { switch (passiveCardForm.PassiveAbility) { case Abilities.Kereskedelem: robot.CanTrade = passiveCardForm.AbilityValue; switch (m_BoardGameForm.CurrentTurn) { case 1: m_BoardGameForm.Robot1TradeNumber.Visible = true; m_BoardGameForm.Robot1TradeNumber.Text += robot.CanTrade; break; case 2: m_BoardGameForm.Robot2TradeNumber.Visible = true; m_BoardGameForm.Robot2TradeNumber.Text += robot.CanTrade; break; case 3: m_BoardGameForm.Robot3TradeNumber.Visible = true; m_BoardGameForm.Robot3TradeNumber.Text += robot.CanTrade; break; default: throw new Exception("This turn is not exist: " + m_BoardGameForm.CurrentTurn); } MessageBox.Show("Mostantól kereskedő lettél! Csak a köröd elején cserélhetsz, azaz ha dobtál már nem teheted meg!", robot.Name); break; case Abilities.Régész: robot.IsArchaeologist = true; MessageBox.Show("Mostantól régész vagy! Ha feltársz valamit az ásatás ideje a felére csökken.", robot.Name); break; case Abilities.Vállalkozó: robot.IsEntrepreneur = true; MessageBox.Show("Mostantól vállalkozó vagy! Miután befejezted a körödet egy bizonyos összeg kerül az egyenlegedre.", robot.Name); break; case Abilities.Óvatos: robot.IsCareful = true; MessageBox.Show("Mostantól óvatos lettél! Minden egyes hupszkártyából húzott balesetet elkerülsz, így nem maradsz ki.", robot.Name); break; case Abilities.Őrangyal: robot.HasAGuardien = passiveCardForm.AbilityValue; MessageBox.Show("Mostantól vane EGY őrangyalod! Ha netán csődbekerülnél ő kisegít.", robot.Name); break; case Abilities.Szárnysegéd: robot.HasAFriend = true; MessageBox.Show("Mostantól van egy szárnysegéded! Jöhet bármi a szárnysegéded fizet mindent, kivéve ha befejezett ásatási területre lépsz. Az neki is drága.", robot.Name); break; case Abilities.Talpraesett: robot.IsPointful = true; MessageBox.Show("Mostantól talpraesett vagy! Mindig tudod mi a dolgod.", robot.Name); break; case Abilities.Tolvaj: robot.CanStealAPassiveAbility = passiveCardForm.AbilityValue; switch (m_BoardGameForm.CurrentTurn) { case 1: m_BoardGameForm.Robot1StealNumber.Visible = true; m_BoardGameForm.Robot1StealNumber.Text += robot.CanStealAPassiveAbility; break; case 2: m_BoardGameForm.Robot2StealNumber.Visible = true; m_BoardGameForm.Robot2StealNumber.Text += robot.CanStealAPassiveAbility; break; case 3: m_BoardGameForm.Robot3StealNumber.Visible = true; m_BoardGameForm.Robot3StealNumber.Text += robot.CanStealAPassiveAbility; break; default: throw new Exception("This turn is not exist: " + m_BoardGameForm.CurrentTurn); } MessageBox.Show("Mostantól tolvaj vagy! Ellophatsz egy képességet valakitől.", robot.Name); break; default: throw new Exception("This ability is not exists: " + passiveCardForm.PassiveAbility); } switch (m_BoardGameForm.CurrentTurn) { case 1: m_UpdateListBoxes.UpdateRobot1PassiveCardListBox(); break; case 2: m_UpdateListBoxes.UpdateRobot2PassiveCardListBox(); break; case 3: m_UpdateListBoxes.UpdateRobot3PassiveCardListBox(); break; default: throw new Exception("Nincs körön lévő Robot"); } } } } //Drawing a hupsz card else if (robot.CurrentPosition == 2 || robot.CurrentPosition == 12 || robot.CurrentPosition == 22 || robot.CurrentPosition == 32) { HupszCard hupszCardForm = new HupszCard(m_BoardGameForm.CurrentTurn, player, robot1, robot2, robot3, m_GameHandler.cards); if (hupszCardForm.ShowDialog() == DialogResult.OK) { switch (hupszCardForm.ActionType) { case HupszAction.Jump: m_GameHandler.JumpWithTheFigureToTheNextPosition(-hupszCardForm.Amount); m_RobotActionControl.RobotAfterChangeHisPositionAction(robot); break; case HupszAction.Accident: HupszAccident(robot, hupszCardForm); break; case HupszAction.Balance: HupszBalance(robot, hupszCardForm); break; default: throw new Exception("Nincs ilyen Action"); } } } //Drawing a Hurra card else if (robot.CurrentPosition == 8 || robot.CurrentPosition == 18 || robot.CurrentPosition == 28 || robot.CurrentPosition == 38) { HurraCard hurraCardForm = new HurraCard(m_BoardGameForm.CurrentTurn, player, robot1, robot2, robot3, m_GameHandler.cards); if (hurraCardForm.ShowDialog() == DialogResult.OK) { switch (hurraCardForm.ActionType) { case HurraAction.Jump: m_GameHandler.JumpWithTheFigureToTheNextPosition(hurraCardForm.Amount); m_RobotActionControl.RobotAfterChangeHisPositionAction(robot); break; case HurraAction.Roll: m_GameHandler.JumpWithTheFigureToTheNextPosition(m_GameHandler.RollTheDice()); m_RobotActionControl.RobotAfterChangeHisPositionAction(robot); break; case HurraAction.Balance: robot.Balance += hurraCardForm.Amount; m_GameHandler.ChangingTheSelectedRobotsBalanceTextValue(robot); break; default: throw new Exception("Nincs ilyen Action"); } } } //Drawing a Property card else { PropertyCardForRobot PropertyCardForm = new PropertyCardForRobot(m_BoardGameForm, player, robot1, robot2, robot3, m_GameHandler.cards, m_Level); if (PropertyCardForm.ShowDialog() == DialogResult.OK) { if (PropertyCardForm.IDontWannaBuy) { MessageBox.Show("Nem akarom megvenni!", robot.Name); } else if (PropertyCardForm.CantBuy) { MessageBox.Show("Nem tudom megvenni!", robot.Name); } else { robot.Balance -= PropertyCardForm.FieldValue; m_GameHandler.ChangingTheSelectedRobotsBalanceTextValue(robot); switch (m_BoardGameForm.CurrentTurn) { case 1: m_UpdateListBoxes.UpdateRobot1PropertyCardListBox(); break; case 2: m_UpdateListBoxes.UpdateRobot2PropertyCardListBox(); break; case 3: m_UpdateListBoxes.UpdateRobot3PropertyCardListBox(); break; default: throw new Exception("Nincs körön lévő Robot"); } Field field = new Field(); field.FieldName = PropertyCardForm.FieldName; field.OwnedField = true; field.FieldOwner = robot; field.FieldValue = PropertyCardForm.FieldValue; field.FieldFinishedValue = PropertyCardForm.FieldFinishedValue; field.FieldLocation = robot.CurrentPosition; //the robot is an Archaeologist so he/she can do it 2x faster if (robot.IsArchaeologist) { double fieldBuildingTurns = PropertyCardForm.FieldBuildingTurns; field.FieldBuildingTurns = (int)Math.Round(fieldBuildingTurns / 2); } else { field.FieldBuildingTurns = PropertyCardForm.FieldBuildingTurns; } m_BoardGameForm.OwnedProperties.Add(field); foreach (Field currentField in m_BoardGameForm.OwnedProperties) { if (robot.CurrentPosition == currentField.FieldLocation && currentField.FieldOwner == robot) { currentField.StartedField = true; m_BoardGameForm.FieldLabel[robot.CurrentPosition].Text = currentField.FieldBuildingTurns.ToString(); m_BoardGameForm.FieldLabel[robot.CurrentPosition].Visible = true; m_BoardGameForm.FieldLabelOwner[robot.CurrentPosition].Text = field.FieldOwner.Name; m_BoardGameForm.FieldLabelOwner[robot.CurrentPosition].Visible = true; double Bill = field.FieldFinishedValue; m_BoardGameForm.PropertyInfo.SetToolTip(m_BoardGameForm.Field[robot.CurrentPosition], "Lelet: " + field.FieldName + ",\n Fizetendő a telek befejezése esetén: " + Math.Round(Bill * 0.4) + "$,\n Fizetendő megkezdett lelet esetén: " + Math.Round(Bill * 0.25) + "$"); } } } } } }
public void RobotWouldLikeToTradeOrNot(Robot robot) { Field robotSmallestProceedsFromProperty = null; Field SomebodysBiggestProceedsFromProperty = null; int min = 3000; int max = 0; bool noOption = false; foreach (Field field in m_BoardGameForm.OwnedProperties) { if (field.StartedField) { if (field.FieldOwner == robot) { if (field.FieldFinishedValue < min) { min = field.FieldFinishedValue; robotSmallestProceedsFromProperty = field; } } else if (field.FieldOwner != robot) { if (field.FieldFinishedValue > max) { max = field.FieldFinishedValue; SomebodysBiggestProceedsFromProperty = field; } } else { noOption = true; } } } if (!noOption) { //robots wanna get the best option and trade his smallest proceeds property to the best proceeds property if (min >= max) { MessageBox.Show("Nem szeretnék most cserélni!", robot.Name); } else if (min < max) { if (robot.CanTrade > 0) { robot.CanTrade -= 1; switch (m_BoardGameForm.CurrentTurn) { case 1: m_BoardGameForm.Robot1TradeNumber.Text = "Ennyi cseréd van még:" + robot.CanTrade; break; case 2: m_BoardGameForm.Robot2TradeNumber.Text = "Ennyi cseréd van még:" + robot.CanTrade; break; case 3: m_BoardGameForm.Robot3TradeNumber.Text = "Ennyi cseréd van még:" + robot.CanTrade; break; default: throw new Exception("This turn is not exist: " + m_BoardGameForm.CurrentTurn); } MessageBox.Show(robotSmallestProceedsFromProperty.ToString() + " teruletemet szeretném elcserélni (" + SomebodysBiggestProceedsFromProperty.FieldOwner + ") : " + SomebodysBiggestProceedsFromProperty.ToString() + " területére.", robot.Name); foreach (Field RobotField in m_BoardGameForm.OwnedProperties) { Player robotFieldOwner = null; if (RobotField == robotSmallestProceedsFromProperty) { robotFieldOwner = RobotField.FieldOwner; foreach (Field PlayerOrRobotField in m_BoardGameForm.OwnedProperties) { if (PlayerOrRobotField == SomebodysBiggestProceedsFromProperty) { //robot's label text change to player and tha same with the player's label m_BoardGameForm.FieldLabelOwner[RobotField.FieldLocation].Text = PlayerOrRobotField.FieldOwner.Name; m_BoardGameForm.FieldLabelOwner[PlayerOrRobotField.FieldLocation].Text = RobotField.FieldOwner.Name; //property cards trade if (PlayerOrRobotField.FieldOwner == player) { for (int i = 0; i < player.MyPropertyCards.Count; i++) { if (player.MyPropertyCards[i].PropertyName == PlayerOrRobotField.FieldName) { m_UpdateListBoxes.AddTheSelectedPropertytoRobotsPropertyListBox(player.MyPropertyCards[i]); m_BoardGameForm.PlayerPropertyCardList.Items.Remove(player.MyPropertyCards[i]); robot.MyPropertyCards.Add(player.MyPropertyCards[i]); player.MyPropertyCards.Remove(player.MyPropertyCards[i]); } } for (int i = 0; i < robot.MyPropertyCards.Count; i++) { if (robot.MyPropertyCards[i].PropertyName == RobotField.FieldName) { m_BoardGameForm.PlayerPropertyCardList.Items.Add(robot.MyPropertyCards[i]); m_UpdateListBoxes.RemoveTheSelectedPropertytoRobotsPropertyListBox(robot.MyPropertyCards[i]); player.MyPropertyCards.Add(robot.MyPropertyCards[i]); robot.MyPropertyCards.Remove(robot.MyPropertyCards[i]); } } } else if (PlayerOrRobotField.FieldOwner == robot1) { for (int i = 0; i < robot1.MyPropertyCards.Count; i++) { if (robot1.MyPropertyCards[i].PropertyName == PlayerOrRobotField.FieldName) { m_UpdateListBoxes.AddTheSelectedPropertytoRobotsPropertyListBox(robot1.MyPropertyCards[i]); m_BoardGameForm.Robot1PropertyCardList.Items.Remove(robot1.MyPropertyCards[i]); robot.MyPropertyCards.Add(robot1.MyPropertyCards[i]); robot1.MyPropertyCards.Remove(robot1.MyPropertyCards[i]); } } for (int i = 0; i < robot.MyPropertyCards.Count; i++) { if (robot.MyPropertyCards[i].PropertyName == RobotField.FieldName) { m_BoardGameForm.Robot1PropertyCardList.Items.Add(robot.MyPropertyCards[i]); m_UpdateListBoxes.RemoveTheSelectedPropertytoRobotsPropertyListBox(robot.MyPropertyCards[i]); robot1.MyPropertyCards.Add(robot.MyPropertyCards[i]); robot.MyPropertyCards.Remove(robot.MyPropertyCards[i]); } } } else if (PlayerOrRobotField.FieldOwner == robot2) { for (int i = 0; i < robot2.MyPropertyCards.Count; i++) { if (robot2.MyPropertyCards[i].PropertyName == PlayerOrRobotField.FieldName) { m_UpdateListBoxes.AddTheSelectedPropertytoRobotsPropertyListBox(robot2.MyPropertyCards[i]); m_BoardGameForm.Robot2PropertyCardList.Items.Remove(robot2.MyPropertyCards[i]); robot.MyPropertyCards.Add(robot2.MyPropertyCards[i]); robot2.MyPropertyCards.Remove(robot2.MyPropertyCards[i]); } } for (int i = 0; i < robot.MyPropertyCards.Count; i++) { if (robot.MyPropertyCards[i].PropertyName == RobotField.FieldName) { m_BoardGameForm.Robot2PropertyCardList.Items.Add(robot.MyPropertyCards[i]); m_UpdateListBoxes.RemoveTheSelectedPropertytoRobotsPropertyListBox(robot.MyPropertyCards[i]); robot2.MyPropertyCards.Add(robot.MyPropertyCards[i]); robot.MyPropertyCards.Remove(robot.MyPropertyCards[i]); } } } else if (PlayerOrRobotField.FieldOwner == robot3) { for (int i = 0; i < robot3.MyPropertyCards.Count; i++) { if (robot3.MyPropertyCards[i].PropertyName == PlayerOrRobotField.FieldName) { m_UpdateListBoxes.AddTheSelectedPropertytoRobotsPropertyListBox(robot3.MyPropertyCards[i]); m_BoardGameForm.Robot3PropertyCardList.Items.Remove(robot3.MyPropertyCards[i]); robot.MyPropertyCards.Add(robot3.MyPropertyCards[i]); robot3.MyPropertyCards.Remove(robot3.MyPropertyCards[i]); } } for (int i = 0; i < robot.MyPropertyCards.Count; i++) { if (robot.MyPropertyCards[i].PropertyName == RobotField.FieldName) { m_BoardGameForm.Robot3PropertyCardList.Items.Add(robot.MyPropertyCards[i]); m_UpdateListBoxes.RemoveTheSelectedPropertytoRobotsPropertyListBox(robot.MyPropertyCards[i]); robot3.MyPropertyCards.Add(robot.MyPropertyCards[i]); robot.MyPropertyCards.Remove(robot.MyPropertyCards[i]); } } } else { throw new Exception("there is no field owner like: " + RobotField.FieldOwner); } m_UpdateListBoxes.UpdateRobot3PropertyCardListBox(); m_UpdateListBoxes.UpdateRobot2PropertyCardListBox(); m_UpdateListBoxes.UpdateRobot1PropertyCardListBox(); m_UpdateListBoxes.UpdatePlayerPropertyCardListBox(); //owners change RobotField.FieldOwner = PlayerOrRobotField.FieldOwner; PlayerOrRobotField.FieldOwner = robotFieldOwner; } } } } //i dont know why is it here //m_BoardGameForm.TradeNumber.Text = "Ennyi cseréd van még:" + robot.CanTrade; } else { MessageBox.Show("Sajnos már nem tudsz többet cserélni.", robot.Name); switch (m_BoardGameForm.CurrentTurn) { case 1: m_BoardGameForm.Robot1TradeNumber.Visible = false; break; case 2: m_BoardGameForm.Robot2TradeNumber.Visible = false; break; case 3: m_BoardGameForm.Robot3TradeNumber.Visible = false; break; default: throw new Exception("This turn is not exist: " + m_BoardGameForm.CurrentTurn); } } } } else { MessageBox.Show("Nem szeretnék most cserélni!", robot.Name); } }