private void cmdPropose_Click(object sender, EventArgs e) { long[] gain = list.getTotalGain(); if (gain[1] > 0) { // accepted MessageBox.Show(String.Format(language.getAString(language.order.proposingAccept), Form1.game.playerList[players[1]].playerName), String.Format(language.getAString(language.order.panNegociatingWith), Form1.game.playerList[players[1]].civName)); list.executeExchange(); this.Close(); } else { negoList tempList = aiNego.fillProp(list, 1); // userChoice ui; if (tempList != null) { list = tempList; populateLBs(); MessageBox.Show( String.Format(language.getAString(language.order.proposingRefusesPropose), Form1.game.playerList[players[1]].playerName), String.Format(language.getAString(language.order.panNegociatingWith), Form1.game.playerList[players[1]].civName) ); } else { MessageBox.Show( String.Format(language.getAString(language.order.proposingRefusesAll), Form1.game.playerList[players[1]].playerName), String.Format(language.getAString(language.order.panNegociatingWith), Form1.game.playerList[players[1]].civName) ); } } }
public static void initNego( byte player, byte otherPlayer ) { if ( !Form1.game.playerList[ player ].memory.attemptedNegoRecently( otherPlayer ) ) { int p = 1; negoList nl = new negoList( new byte[] { otherPlayer, player } ); int[] whw = nl.whatHeWants( p ); int totInterestings = 0, totInterest = 0; for ( int i = 0; i < whw.Length; i++ ) if ( whw[ i ] > 0 ) { totInterestings ++; totInterest += whw[ i ]; } if ( totInterestings > 0 ) for ( int i = 0; i < nl.Length; i++ ) if ( whw[ i ] > totInterestings * 33 / 100 /*&& whw[ i ] < totInterestings * 66 / 100*/ ) nl.add( i ); nl = fillProp( nl, (p+1)%2 ); if ( nl != null ) { for ( int p1 = 0; p1 < 2; p1 ++ ) Form1.game.playerList[ nl.players[ p1 ] ].memory.addAttemptedNego( nl.players[ (p1+1)%2 ] ); if ( acceptToInitNego( nl, p ) ) { if ( otherPlayer == Form1.game.curPlayerInd ) { wC.show = false; frmNegociation fn = new frmNegociation( Form1.game.curPlayerInd, player, -1 ); fn.list = nl; fn.populateLBs(); fn.ShowDialog(); wC.show = true; } else { nl = fillProp( nl, p ); if ( nl != null ) nl.executeExchange(); } } } } }
public static void initNego(byte player, byte otherPlayer) { if (!Form1.game.playerList[player].memory.attemptedNegoRecently(otherPlayer)) { int p = 1; negoList nl = new negoList(new byte[] { otherPlayer, player }); int[] whw = nl.whatHeWants(p); int totInterestings = 0, totInterest = 0; for (int i = 0; i < whw.Length; i++) { if (whw[i] > 0) { totInterestings++; totInterest += whw[i]; } } if (totInterestings > 0) { for (int i = 0; i < nl.Length; i++) { if ( whw[i] > totInterestings * 33 / 100 /*&& * whw[ i ] < totInterestings * 66 / 100*/ ) { nl.add(i); } } } nl = fillProp(nl, (p + 1) % 2); if (nl != null) { for (int p1 = 0; p1 < 2; p1++) { Form1.game.playerList[nl.players[p1]].memory.addAttemptedNego(nl.players[(p1 + 1) % 2]); } if (acceptToInitNego(nl, p)) { if (otherPlayer == Form1.game.curPlayerInd) { wC.show = false; frmNegociation fn = new frmNegociation(Form1.game.curPlayerInd, player, -1); fn.list = nl; fn.populateLBs(); fn.ShowDialog(); wC.show = true; } else { nl = fillProp(nl, p); if (nl != null) { nl.executeExchange(); } } } } } }