source: geniuswebcore/geniusweb/protocol/session/mopac/phase/OfferPhase.py@ 88

Last change on this file since 88 was 88, checked in by Bart Vastenhouw, 2 years ago

Added python SimpleRunner GUI

File size: 1.6 KB
Line 
1from typing import List, Any
2
3from geniusweb.actions.Action import Action
4from geniusweb.actions.EndNegotiation import EndNegotiation
5from geniusweb.actions.Offer import Offer
6from geniusweb.actions.PartyId import PartyId
7from geniusweb.inform.Inform import Inform
8from geniusweb.inform.YourTurn import YourTurn
9from geniusweb.protocol.ProtocolException import ProtocolException
10from geniusweb.protocol.session.mopac.phase.DefaultPhase import DefaultPhase
11from geniusweb.protocol.session.mopac.phase.Phase import Phase
12from geniusweb.protocol.session.mopac.phase.VotingPhase import VotingPhase
13
14
15class OfferPhase (DefaultPhase):
16
17
18 def With(self, actor:PartyId , action:Action ,timems:int)->"OfferPhase" :
19 try:
20 self._checkAction(actor, action, timems)
21 except ProtocolException as ex:
22 return self.WithException(ex)
23 return OfferPhase(self._partyStates.WithAction(action), self._deadline, self._evaluator);
24
25 def getInform(self)->Inform :
26 return YourTurn()
27
28 def WithException(self, e:ProtocolException) -> "OfferPhase" :
29 # don't print to stdout
30 # System.out.println("Party kicked because of protocol exception:" + e);
31 return OfferPhase(self._partyStates.WithException(e), self._deadline,
32 self._evaluator)
33
34 def finish(self)->Phase :
35 return OfferPhase(self._partyStates.finish(), self._deadline, self._evaluator)
36
37 def _checkedNext(self, deadln:int) ->VotingPhase :
38 return VotingPhase(self._getOffers(), self._partyStates.flush(), deadln,
39 self._evaluator)
40
41 def _getOffers(self)->List[Offer] :
42 return self._partyStates.getActionsOfType(Offer)
43
44 def getAllowedActions(self)->List[Any] : #Class<? extends Action>>
45 return [Offer, EndNegotiation]
46
Note: See TracBrowser for help on using the repository browser.