Changeset 11 for protocol/src/main/java
- Timestamp:
- 01/30/20 16:52:38 (5 years ago)
- Location:
- protocol/src/main/java/geniusweb/protocol
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
protocol/src/main/java/geniusweb/protocol/session/SessionState.java
r1 r11 10 10 import geniusweb.protocol.NegoState; 11 11 import geniusweb.protocol.session.saop.SAOPState; 12 import geniusweb.protocol.session.shaop.SHAOPState; 12 13 13 14 /** … … 33 34 * the protocol. As uaual, mark non-serializable fields as transient. 34 35 */ 35 @JsonSubTypes({ @JsonSubTypes.Type(value = SAOPState.class) }) 36 @JsonSubTypes({ @JsonSubTypes.Type(value = SAOPState.class), 37 @JsonSubTypes.Type(value = SHAOPState.class) }) 36 38 37 39 public interface SessionState extends NegoState { -
protocol/src/main/java/geniusweb/protocol/session/shaop/BareSHAOPState.java
r10 r11 32 32 protected final ProtocolException error; 33 33 34 protected final int actorNr;34 protected final int teamNr; 35 35 36 36 protected final Map<PartyId, Integer> partyNumbers; … … 43 43 * list 44 44 * @param conns the currently existing connections. Can be empty/null. 45 * Each connection represents another party. Normally 46 * there is exactly 1 connection for every party. The 47 * protocol should check this. 45 * Each connection represents another party. Normally the 46 * connections are in the order SHAOP1,COB1,SHAOP2,COB2,.. 47 * so 2 parties for each team. The protocol should check 48 * this. 48 49 * @param progr the {@link Progress} that governs this session. Can be 49 50 * null if session did not yet start. … … 54 55 * are bugs (not ProtocolExceptions) and should result in 55 56 * a throw. 56 * @param actorNr the actor that has the turn, index {@link #connections} 57 * @param teamNr the teamnr (0,1,2..) that has the turn. 2* gives index 58 * {@link #connections} and settings 57 59 * @param partyNrs a map for each known PartyId to a number. The number is 58 60 * the index in both {@link SHAOPSettings#getTeams()} and … … 64 66 public BareSHAOPState(List<Action> actions, 65 67 ProtocolToPartyConnections conns, Progress progr, 66 SHAOPSettings settings, ProtocolException e, int actorNr,68 SHAOPSettings settings, ProtocolException e, int teamNr, 67 69 Map<PartyId, Integer> partyNrs, Map<PartyId, Double> spent) { 68 70 if (conns == null) { … … 97 99 this.settings = settings; 98 100 this.error = e; 99 this. actorNr = actorNr;101 this.teamNr = teamNr; 100 102 } 101 103 … … 106 108 /** 107 109 * 108 * @return party ID of current actorNr110 * @return party ID of current team leader (SHAOP party) 109 111 */ 110 public PartyId getCurrent Actor() {111 return connections.get( actorNr).getParty();112 public PartyId getCurrentTeam() { 113 return connections.get(2 * teamNr).getParty(); 112 114 } 113 115 -
protocol/src/main/java/geniusweb/protocol/session/shaop/SHAOP.java
r10 r11 313 313 .send(new ActionDone(action)); 314 314 } else { 315 if (!partyconn.getParty().equals(state.getCurrent Actor()))315 if (!partyconn.getParty().equals(state.getCurrentTeam())) 316 316 throw new ProtocolException( 317 317 "Party acts without having the turn", … … 331 331 */ 332 332 private synchronized void nextTurn() { 333 PartyId party = state.getCurrent Actor();333 PartyId party = state.getCurrentTeam(); 334 334 try { 335 335 state.getConnections().get(party).send(new YourTurn()); -
protocol/src/main/java/geniusweb/protocol/session/shaop/SHAOPSettings.java
r10 r11 62 62 63 63 /** 64 *65 * @param n an index number into the {@link #getTeams()} list.66 * @return true iff that participant is a SHAOP party.67 */68 public boolean isShaopParty(int n) {69 return (n & 1) == 0;70 }71 72 /**73 64 * @return the deadline for this negotiation 74 65 */ … … 83 74 * party. 84 75 */ 76 @Override 85 77 public List<PartyWithProfile> getAllParties() { 86 78 return participants.stream().map(team -> team.getAllParties()) -
protocol/src/main/java/geniusweb/protocol/session/shaop/SHAOPState.java
r10 r11 41 41 @JsonProperty("settings") SHAOPSettings settings, 42 42 @JsonProperty("error") ProtocolException e, 43 @JsonProperty(" actorNr") int actorNr,43 @JsonProperty("teamNr") int teamNr, 44 44 @JsonProperty("partyNumbers") Map<PartyId, Integer> partytNumbers, 45 45 @JsonProperty("totalSpent") Map<PartyId, Double> spent) { 46 super(actions, conns, progress, settings, e, actorNr, partytNumbers,46 super(actions, conns, progress, settings, e, teamNr, partytNumbers, 47 47 spent); 48 48 } … … 73 73 */ 74 74 public boolean isShaopParty(PartyId party) { 75 return settings.isShaopParty(partyNumbers.get(party));75 return (partyNumbers.get(party) & 1) == 0; 76 76 } 77 77 … … 79 79 * 80 80 * @param party a Party Id 81 * @return the PartyId of the party 81 * @return the PartyId of the party (COB and SHAOP are partners) 82 82 */ 83 83 public PartyId getPartner(PartyId party) { … … 132 132 newNumbers.put(connection.getParty(), connections.size()); 133 133 return new SHAOPState(actions, newconns, progress, settings, null, 134 actorNr, newNumbers, totalSpent);134 teamNr, newNumbers, totalSpent); 135 135 } 136 136 … … 144 144 public SHAOPState with(ProtocolException e) { 145 145 return new SHAOPState(actions, connections, progress, settings, e, 146 actorNr, partyNumbers, totalSpent);146 teamNr, partyNumbers, totalSpent); 147 147 } 148 148 … … 162 162 } 163 163 return new SHAOPState(actions, connections, newprogress, settings, 164 error, actorNr, partyNumbers, totalSpent);164 error, teamNr, partyNumbers, totalSpent); 165 165 } 166 166 … … 259 259 List<Action> newactions = new LinkedList<>(getActions()); 260 260 newactions.add(action); 261 int new Actor = actorNr;261 int newTeam = teamNr; 262 262 if (action instanceof ElicitComparison) { 263 263 Object cost = getPartyProfile(partyid).getParty().getParameters() … … 276 276 } else { 277 277 // shaop party does real action, move to next SHAOP party. 278 new Actor = (actorNr + 2) % settings.getTeams().size();278 newTeam = (teamNr + 1) % settings.getTeams().size(); 279 279 if (newprogress instanceof ProgressRounds) { 280 280 newprogress = ((ProgressRounds) newprogress).advance(); … … 282 282 } 283 283 return new SHAOPState(newactions, connections, newprogress, settings, 284 null, new Actor, partyNumbers, newSpent);284 null, newTeam, partyNumbers, newSpent); 285 285 286 286 } … … 298 298 if (!isShaopParty(actor)) 299 299 throw new IllegalArgumentException( 300 " Illegal action for COB party" + action);300 "Only SHAOP party can execute " + action); 301 301 // real action only allowed if party has the turn. 302 if (!actor.equals(connections.get( actorNr).getParty())) {302 if (!actor.equals(connections.get(2 * teamNr).getParty())) { 303 303 throw new IllegalArgumentException("Party does not have the turn "); 304 304 } -
protocol/src/main/java/geniusweb/protocol/tournament/allpermutations/AllPermutationsSettings.java
r10 r11 67 67 public class AllPermutationsSettings implements TournamentSettings { 68 68 69 public static final String COB_PARTY = "comparebids-1.2.0"; 69 70 private final List<PartyWithParameters> parties; 70 71 private final List<ProfileRef> profiles; … … 292 293 PartyWithParameters cobparty = new PartyWithParameters(new PartyRef( 293 294 partyuri.getScheme() + "://" + partyuri.getAuthority() 294 + partypath + "/ comparebids-1.0.0"),295 + partypath + "/" + COB_PARTY), 295 296 new Parameters()); 296 297 return new PartyWithProfile(cobparty, cobprof);
Note:
See TracChangeset
for help on using the changeset viewer.