public override void enableEventObjects() { tradeWindow = new TradeWindow(); tradeWindow.loadYearOfPlenty(theBoard.currentPlayer); tradeWindow.Show(); tradeWindow.Closing += executeUpdate; }
public void onTradeEnded(Object sender, EventArgs e) { //The trade ended. enableEventObjects(); tradeWindow = null; currentState = State.Wait; }
public void Init(Item item, ushort index, TradeWindow parentWindow) { this.item = item; this.parentWindow = parentWindow; name = transform.FindChild("Item Name").GetComponent <Text>(); Transform q = transform.FindChild("Quantity"); if (q != null) { quantity = q.GetComponent <Text>(); } price = transform.FindChild("Price").GetComponent <Text>(); Transform t = transform.FindChild("PriceRange"); if (t != null) { priceRange = t.GetComponent <Text>(); } updateText(); this.index = index; }
public void bankTrade(Object sender, EventArgs e) { disableEventObjects(); tradeWindow = new TradeWindow(); tradeWindow.loadBankTrade(theBoard.currentPlayer); tradeWindow.Closing += onTradeEnded; currentState = State.Trade; tradeWindow.Show(); }
public static void HandleUnacceptTrade(IRealmClient client, RealmPacketIn packet) { TradeWindow tradeWindow = client.ActiveCharacter.TradeWindow; if (tradeWindow == null) { return; } tradeWindow.UnacceptTrade(false); }
public static void HandleSetTradeGold(IRealmClient client, RealmPacketIn packet) { TradeWindow tradeWindow = client.ActiveCharacter.TradeWindow; if (tradeWindow == null) { return; } uint money = packet.ReadUInt32(); tradeWindow.SetMoney(money, false); }
public static void HandleClearTradeItem(IRealmClient client, RealmPacketIn packet) { TradeWindow tradeWindow = client.ActiveCharacter.TradeWindow; if (tradeWindow == null) { return; } byte tradeSlot = packet.ReadByte(); tradeWindow.ClearTradeItem(tradeSlot, false); }
public TestForm() { InitializeComponent(); log = new LogToText(this.txtLog, this); touch = new Touch(log); buildingSelector = new BuildingSelector(log, touch); captureScreen = new CaptureScreen(log); tradeWindow = new TradeWindow(captureScreen, log); navigateToBuilding = new NavigateToBuilding(log, touch, buildingSelector, tradeWindow); resourceReader = new CommerceResourceReader(log, touch); buildItemList = CommerceItemBuild.CreateResourceList(); }
public static void HandleIgnoreTrade(IRealmClient client, RealmPacketIn packet) { TradeWindow tradeWindow = client.ActiveCharacter.TradeWindow; if (tradeWindow == null) { SendTradeStatus(client, TradeStatus.PlayerNotFound); } else { tradeWindow.StopTrade(TradeStatus.PlayerIgnored, false); } }
public static void HandleBeginTrade(IRealmClient client, RealmPacketIn packet) { TradeWindow tradeWindow = client.ActiveCharacter.TradeWindow; if (tradeWindow == null) { SendTradeStatus(client, TradeStatus.PlayerNotFound); } else { tradeWindow.AcceptTradeProposal(); } }
public static void HandleBusyTrade(IRealmClient client, RealmPacketIn packet) { TradeWindow tradeWindow = client.ActiveCharacter.TradeWindow; if (tradeWindow == null) { TradeHandler.SendTradeStatus((IPacketReceiver)client, TradeStatus.PlayerNotFound); } else { tradeWindow.StopTrade(TradeStatus.PlayerBusy, false); } }
public BuyForm() { InitializeComponent(); log = new NoOpLogger(); touch = new Touch(log); captureScreen = new CaptureScreen(new NoOpLogger(), touch); resourceReader = new CommerceResourceReader(log, touch); buildingSelector = new BuildingSelector(log, touch); tradeWindow = new TradeWindow(captureScreen, log); tradePanelCapture = new TradePanelCapture(tradeWindow); navigateToBuilding = new NavigateToBuilding(log, touch, buildingSelector, tradeWindow); buildItemList = CommerceItemBuild.CreateResourceList(); tradeWindow.PictureBox = this.pictureBox1; var pictureBoxes = new List <PictureBox>(); var textBoxes = new List <TextBox>(); pictureBoxes.Add(this.pb1); pictureBoxes.Add(this.pb2); pictureBoxes.Add(this.pb3); pictureBoxes.Add(this.pb4); pictureBoxes.Add(this.pb5); pictureBoxes.Add(this.pb6); pictureBoxes.Add(this.pb7); pictureBoxes.Add(this.pb8); textBoxes.Add(this.tb1); textBoxes.Add(this.tb2); textBoxes.Add(this.tb3); textBoxes.Add(this.tb4); textBoxes.Add(this.tb5); textBoxes.Add(this.tb6); textBoxes.Add(this.tb7); textBoxes.Add(this.tb8); itemHashes = new ItemHashes(pictureBoxes, textBoxes); LoadShoppingLists(); salesman = new Salesman(touch, tradeWindow, tradePanelCapture, itemHashes, navigateToBuilding, log); craftsman = new Craftsman(log, buildingSelector, navigateToBuilding, touch, resourceReader, buildItemList); }
public BotForm() { InitializeComponent(); log = new LogToText(this.txtLog, this); touch = new Touch(log); buildingSelector = new BuildingSelector(log, touch); captureScreen = new CaptureScreen(log); tradeWindow = new TradeWindow(captureScreen, log); navigateToBuilding = new NavigateToBuilding(log, touch, buildingSelector, tradeWindow); resourceReader = new CommerceResourceReader(log, touch); buildItemList = CommerceItemBuild.CreateResourceList(); tradePanelCapture = new TradePanelCapture(tradeWindow); itemHashes = new ItemHashes(new List <PictureBox>(), new List <TextBox>()); itemHashes.ReadHashes(); salesman = new Salesman(touch, tradeWindow, tradePanelCapture, itemHashes, navigateToBuilding, log); craftsman = new Craftsman(log, buildingSelector, navigateToBuilding, touch, resourceReader, buildItemList); }
public override void executeUpdate(Object sender, EventArgs e) { switch (state) { case 0: if (playersToGiveUpCards.Count() > 0) { theBoard.currentPlayer = playersToGiveUpCards[0]; MessageBox.Show(playersToGiveUpCards[0].getName() + " is holding more than 7 cards. Please select ones you wish to give up."); //make the player at index 0 give up their cards disableEventObjects(); TradeWindow tradeWindow = new TradeWindow(); tradeWindow.loadPlayerResourceLoss(playersToGiveUpCards[0]); tradeWindow.Closing += finishedStealing; tradeWindow.Show(); playersToGiveUpCards.Remove(playersToGiveUpCards[0]); } else { theBoard.currentPlayer = activePlayer; state++; executeUpdate(sender, e); } break; case 1: //Run the regular robber event. ThiefEvt evt = new ThiefEvt(); disableEventObjects(); evt.beginExecution(theBoard, this); state++; break; case 2: endExecution(); break; } }
public TradeDepot() { InitializeComponent(); var log = new LogToText(this.txtLog, this); captureScreen = new CaptureScreen(log); touch = new Touch(log); tradeWindow = new TradeWindow(captureScreen, log); tradePanelCapture = new TradePanelCapture(tradeWindow); buildingSelector = new BuildingSelector(log, touch); navigateToBuilding = new NavigateToBuilding(log, touch, buildingSelector, tradeWindow); tradeWindow.PictureBox = this.pictureBox1; var pictureBoxes = new List <PictureBox>(); var textBoxes = new List <TextBox>(); pictureBoxes.Add(this.pb1); pictureBoxes.Add(this.pb2); pictureBoxes.Add(this.pb3); pictureBoxes.Add(this.pb4); pictureBoxes.Add(this.pb5); pictureBoxes.Add(this.pb6); pictureBoxes.Add(this.pb7); pictureBoxes.Add(this.pb8); textBoxes.Add(this.tb1); textBoxes.Add(this.tb2); textBoxes.Add(this.tb3); textBoxes.Add(this.tb4); textBoxes.Add(this.tb5); textBoxes.Add(this.tb6); textBoxes.Add(this.tb7); textBoxes.Add(this.tb8); itemHashes = new ItemHashes(pictureBoxes, textBoxes); itemHashes.ReadHashes(); salesman = new Salesman(touch, tradeWindow, tradePanelCapture, itemHashes, navigateToBuilding, log); }
public void Init(Item item, ushort index, TradeWindow parentWindow) { this.item = item; this.parentWindow = parentWindow; name = transform.FindChild("Item Name").GetComponent<Text>(); Transform q = transform.FindChild("Quantity"); if (q != null) { quantity = q.GetComponent<Text>(); } price = transform.FindChild("Price").GetComponent<Text>(); Transform t = transform.FindChild("PriceRange"); if (t != null) { priceRange = t.GetComponent<Text>(); } updateText(); this.index = index; }
public override void executeUpdate(Object sender, EventArgs e) { switch (currentState) { case State.Wait: if (sender == theBoard.btnEndTurn) { //End turn. theBoard.addEventText(UserMessages.PlayerEndedTurn(theBoard.currentPlayer)); endExecution(); return; } else if (sender is Settlement) { Settlement location = (Settlement)sender; try { //Try to build the settlement/upgrade city. ((Settlement)sender).buildSettlement(theBoard.currentPlayer, true, true); //Take resources if (location.city()) { //take city resources Board.TheBank.takePayment(theBoard.currentPlayer, Bank.CITY_COST); theBoard.addEventText(UserMessages.PlayerBuiltACity(theBoard.currentPlayer)); theBoard.checkForWinner(); } else { //take settlement resources Board.TheBank.takePayment(theBoard.currentPlayer, Bank.SETTLEMENT_COST); theBoard.addEventText(UserMessages.PlayerPlacedASettlement(theBoard.currentPlayer)); theBoard.checkForWinner(); } } catch (BuildError be) { theBoard.addEventText(be.Message); } } else if (sender is Road) { //Try to build the road try { ((Road)sender).buildRoad(theBoard.currentPlayer, true); //Take the resources. Board.TheBank.takePayment(theBoard.currentPlayer, Bank.ROAD_COST); theBoard.addEventText(UserMessages.PlayerPlacedARoad(theBoard.currentPlayer)); //RUN LONGEST ROAD CHECK theBoard.checkForWinner(); } catch (BuildError be) { theBoard.addEventText(be.Message); } } else if (sender == theBoard.pbBuildDevelopmentCard) { //We want to give the player a development card. try { DevelopmentCard devC = Board.TheBank.purchaseDevelopmentCard(theBoard.currentPlayer); devC.setPlayable(false); theBoard.currentPlayer.giveDevelopmentCard(devC); Board.TheBank.takePayment(theBoard.currentPlayer, Bank.DEV_CARD_COST); theBoard.addEventText(UserMessages.PlayerPurchasedADevCard(theBoard.currentPlayer)); theBoard.checkForWinner(); } catch (BuildError be) { theBoard.addEventText(be.Message); } } else if (sender is DevelopmentCard) { DevelopmentCard card = (DevelopmentCard)sender; if (card.isPlayable()) { switch (card.getType()) { case DevelopmentCard.DevCardType.Road: //Player is allowed to place two roads for no cost RoadBuildingEvt evt = new RoadBuildingEvt(); evt.beginExecution(theBoard, this); disableEventObjects(); //Remove this card from the player's hand. theBoard.currentPlayer.takeDevelopmentCard(card.getType()); break; case DevelopmentCard.DevCardType.Plenty: //Player is allowed to take any two resources from the bank YearOfPlentyEvt yr = new YearOfPlentyEvt(); yr.beginExecution(theBoard, this); disableEventObjects(); //Remove this card from the player's hand. They DO NOT go back to the bank theBoard.currentPlayer.takeDevelopmentCard(card.getType()); break; case DevelopmentCard.DevCardType.Knight: //Launch the thief event if (!card.used) { ThiefEvt thevt = new ThiefEvt(); thevt.beginExecution(theBoard, this); disableEventObjects(); card.used = true; theBoard.checkForWinner(); } break; case DevelopmentCard.DevCardType.Monopoly: //Player names a resource, all players give this player that resource they carry MonopolyEvt monEvt = new MonopolyEvt(); monEvt.beginExecution(theBoard, this); disableEventObjects(); //Remove this card from the player's hand. They DO NOT go back to the bank theBoard.currentPlayer.takeDevelopmentCard(card.getType()); break; } } else { if (card.getType() != DevelopmentCard.DevCardType.Victory) { theBoard.addEventText("You must wait until the next turn to play that card."); } } } else if (sender is Harbor) { Harbor hb = (Harbor)sender; if (hb.playerHasValidSettlement(theBoard.currentPlayer)) { if (TradeWindow.canPlayerTradeWithHarbor(hb, theBoard.currentPlayer)) { disableEventObjects(); tradeWindow = new TradeWindow(); tradeWindow.loadHarborTrade(hb, theBoard.currentPlayer); tradeWindow.Closing += onTradeEnded; currentState = State.Trade; tradeWindow.Show(); } else { theBoard.addEventText(BuildError.NOT_ENOUGH_RESOURCES); } } else { theBoard.addEventText(UserMessages.PlayerDoesNotHaveAdjascentSettlement); } } else if (sender is TradeProposition) { var proposition = (TradeProposition)sender; Board.TheBank.tradeWithBank( theBoard.currentPlayer, proposition, theBoard.getPlayerBankCosts(theBoard.currentPlayer) ); theBoard.addEventText($"{theBoard.currentPlayer.getName()} traded {proposition.selledResource} for {proposition.boughtResource}"); } break; case State.Trade: //Should not be able to reach this statement. break; } //if (theBoard.currentPlayer.isAI) //{ // var move = theBoard.currentPlayer.agent.makeMove(theBoard.getBoardState()); // executeUpdate(move, null); //} }
public override void disableEventObjects() { tradeWindow = null; }