Last change
on this file since 89 was 89, checked in by Bart Vastenhouw, 3 years ago |
refactor to help reusing partiesserver
|
File size:
1.2 KB
|
Rev | Line | |
---|
[89] | 1 | from typing import Dict, List
|
---|
| 2 |
|
---|
| 3 | from geniusweb.actions.Offer import Offer
|
---|
| 4 | from geniusweb.actions.PartyId import PartyId
|
---|
| 5 | from geniusweb.inform.Inform import Inform
|
---|
| 6 |
|
---|
| 7 |
|
---|
| 8 | class Voting (Inform):
|
---|
| 9 | '''
|
---|
| 10 | Informs a party that it's time to do voting.
|
---|
| 11 | '''
|
---|
| 12 | def __init__(self, offers:List[Offer] , powers:Dict[PartyId,int] ):
|
---|
| 13 | self._offers = offers
|
---|
| 14 | self._powers = powers
|
---|
| 15 |
|
---|
| 16 | def getOffers(self) -> List[Offer] :
|
---|
| 17 | '''
|
---|
| 18 | @return list of bids to be voted on
|
---|
| 19 | '''
|
---|
| 20 | return list(self._offers);
|
---|
| 21 |
|
---|
| 22 | def getPowers(self) -> Dict[PartyId, int]:
|
---|
| 23 | '''
|
---|
| 24 | @return map with the power of each party in the negotiation. This map may
|
---|
| 25 | contain parties that are already finished, eg they reached an
|
---|
| 26 | agreement or walked away.
|
---|
| 27 | '''
|
---|
| 28 | return dict(self._powers)
|
---|
| 29 |
|
---|
| 30 | def __eq__(self, other):
|
---|
| 31 | return isinstance(other, self.__class__) and \
|
---|
| 32 | self._offers==other._offers and self._powers==other._powers
|
---|
| 33 |
|
---|
| 34 | def __hash__(self):
|
---|
| 35 | return hash((tuple(self._offers), tuple(self._powers.items())))
|
---|
| 36 |
|
---|
| 37 | def __repr__(self)->str :
|
---|
| 38 | return "Voting[" + str(self._offers) + "," + str(self._powers) + "]";
|
---|
| 39 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.