dd.sim
Class Proposal

java.lang.Object
  extended bydd.sim.SimObject
      extended bydd.sim.Proposal
All Implemented Interfaces:
java.lang.Comparable, java.io.Serializable
Direct Known Subclasses:
AntiCasinoCampaign, BeachRenourishment, BirdWatchingAds, BoilWaterNotices, BreedingSiteReduction, Buyout, Center, ChooseYourHome, Code, DevelopmentPlan, Downtown, Education, EndTurn, EndTurn3, EOC, FinancialAssistance, Highway, Historic, ImproveDrainage, Lab, LowerHousingStandards, Monitor, MosquitoControl, NFIP_CRS, OpenSpace, PollutionRegulations, PromoteTourism, PublicAwarenessProgram, RaisePropertyTaxes, RaiseSalesTax, ReduceLicensingFees, RelaxHousingRegulations, RemediationAssistance, RestrictPermits, Retrofit, Seawall, SepticEnforcement, Sewers, ShorelineArmoring, SolicitIndustry, TaxBreaks, TreeTrimming, UndercurrentStabilizers, VisitorUseFees, Waterfront, WaterPurificationPlant, ZoneAffordableHousing

public class Proposal
extends SimObject
implements java.lang.Comparable

A policy change in the DLUG game. The core structure of DLUG game play involves choosing between proposals, determining which proposals should be enacted, voting on the proposals, and (if they pass) enacting the proposals, causing an effect on the rest of the game. A proposal is a generic thing that will effect the city, such as building new bridges, changing zoning laws, and modifying taxes.

Subclasses wishing to extend the generic proposal may want to implement the following methods, but should always call the superclass methods here:

Author:
Eric Scharff
See Also:
Serialized Form

Field Summary
static CostTable costTable
           
static java.lang.String MAYBE_PHRASE
           
static java.lang.String OPPOSE
          Indicates a player opposes (is against) this proposal.
static java.lang.String OPPOSE_PHRASE
           
static java.lang.String STATUS_AUTOFAIL
           
static java.lang.String STATUS_FAILED
           
static java.lang.String STATUS_INFORMATIONAL
           
static java.lang.String STATUS_KEY
           
static java.lang.String STATUS_NEW
           
static java.lang.String STATUS_PASSED
           
static java.lang.String STATUS_PLAYED
           
static java.lang.String STATUS_UNPICKED
           
static java.lang.String STATUS_WITHDRAWN
           
static java.lang.String SUPPORT
          Indicates a player supports (is for) this proposal.
static java.lang.String SUPPORT_PHRASE
           
 
Fields inherited from class dd.sim.SimObject
attributes
 
Constructor Summary
Proposal()
          Configures the proposal.
Proposal(java.lang.String title)
           
 
Method Summary
 void addConfigParameter(ConfigParameter parameter)
           
 void calculateCosts()
           
 void castVote(java.lang.String playerID, int newVote)
          Casts a vote for (or against) this proposal.
 int compareTo(java.lang.Object o)
           
 void configure(ConfigParameter c, boolean val)
           
 void configure(ConfigParameter c, int index)
           
 void configure(ConfigParameter c, java.lang.String val)
           
 void configureFromSum(java.lang.String configSum)
           
 SimObject duplicate()
          Duplicates the Proposal by calling SimObject.duplicate(), then iterating over the properties and removing all the instances of "proposalSupportFor" (that is, opinions).
 void enact(GameRoot root)
          Enable the proposal.
 void enact(GameRoot root, java.util.Random rng)
          This is stub method to be overridden by subclasses; in Proposal, it just calls enact(root).
 java.util.List enumerateConfigurations()
           
 java.lang.String getAbbrev()
          Returns an string containing an abbreviated description of the proposal's configuration details.
 java.util.ArrayList getConfigParameters()
           
 java.lang.String getConfigSum()
           
 java.lang.String getDebriefingText()
          Get text for the debriefing turn.
 java.lang.String getDescription()
           
 float getEconCost()
           
 java.lang.String getFamily()
           
 java.util.Set getLegendIcons()
           
 java.util.Set getMapIcons()
           
 java.lang.String getOwnerID()
           
 java.lang.String getPlayerOpinion(Player player)
          Gets a player's opinion about the this proposal.
 java.lang.String getPlayerOpinion(Player player, java.lang.String defaultValue)
           
 int getPlayerVotesAgainst(Player player)
           
 int getPlayerVotesFor(Player player)
          Returns the player's vote on this proposal.
 java.lang.String getProposalID()
           
 float getSocialCost()
           
 java.lang.String getStatus()
           
 java.lang.String getTitle()
           
 int getTurn()
           
 int getVotesAgainst()
           
 int getVotesFor()
           
 int getVoteTally()
          Returns the "global" vote tally for this proposal.
 boolean isActive()
           
 boolean isDuplicate(Proposal p)
          Determines whether this proposal is a duplicate of the proposal given as an argument.
static void main(java.lang.String[] args)
           
 boolean ownedBy(Player p)
           
 void resetVoteTally()
          Resets the vote tally for this proposal to zero.
 void setDescription(java.lang.String description)
           
 void setFamily(java.lang.String family)
           
 void setOwnerID(java.lang.String ownerID)
           
 void setPlayerOpinion(Player player, java.lang.String pref)
          Sets a player's opinion about the this proposal.
 void setProposalID(java.lang.String id)
           
 void setStatus(java.lang.String status)
           
 void setTitle(java.lang.String title)
           
 void setTurn(int t)
           
 
Methods inherited from class dd.sim.SimObject
addPropertyChangeListener, addPropertyChangeListener, debug, error, fatal, filter, filter, firePropertyChange, getAttribute, getAttribute, getAttributes, getGlobalAttribute, getObjectAttribute, getObjectAttribute, incrementAttribute, incrementAttribute, isSet, log, out, readFromXML, readFromXML, removeAttribute, removePropertyChangeListener, setAttribute, setAttribute, setAttribute, setAttributes, setGlobalAttribute, warning, writeText, writeXML, writeXML
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STATUS_KEY

public static final java.lang.String STATUS_KEY
See Also:
Constant Field Values

STATUS_NEW

public static final java.lang.String STATUS_NEW
See Also:
Constant Field Values

STATUS_PLAYED

public static final java.lang.String STATUS_PLAYED
See Also:
Constant Field Values

STATUS_PASSED

public static final java.lang.String STATUS_PASSED
See Also:
Constant Field Values

STATUS_FAILED

public static final java.lang.String STATUS_FAILED
See Also:
Constant Field Values

STATUS_WITHDRAWN

public static final java.lang.String STATUS_WITHDRAWN
See Also:
Constant Field Values

STATUS_UNPICKED

public static final java.lang.String STATUS_UNPICKED
See Also:
Constant Field Values

STATUS_AUTOFAIL

public static final java.lang.String STATUS_AUTOFAIL
See Also:
Constant Field Values

STATUS_INFORMATIONAL

public static final java.lang.String STATUS_INFORMATIONAL
See Also:
Constant Field Values

SUPPORT_PHRASE

public static final java.lang.String SUPPORT_PHRASE
See Also:
Constant Field Values

OPPOSE_PHRASE

public static final java.lang.String OPPOSE_PHRASE
See Also:
Constant Field Values

MAYBE_PHRASE

public static final java.lang.String MAYBE_PHRASE
See Also:
Constant Field Values

costTable

public static CostTable costTable

SUPPORT

public static final java.lang.String SUPPORT
Indicates a player supports (is for) this proposal.

See Also:
Constant Field Values

OPPOSE

public static final java.lang.String OPPOSE
Indicates a player opposes (is against) this proposal.

See Also:
Constant Field Values
Constructor Detail

Proposal

public Proposal()
Configures the proposal. Note that classes extending Proposal will generally use the constructor to initialize default parameters. You don't need to call the constructor unless you want to create a specific version of the proposal with the default parameters, or if you're calling one of the overloaded functions like @link #enact enact().


Proposal

public Proposal(java.lang.String title)
Method Detail

isActive

public boolean isActive()

getTitle

public java.lang.String getTitle()

setTitle

public void setTitle(java.lang.String title)

getTurn

public int getTurn()

setTurn

public void setTurn(int t)

getConfigParameters

public java.util.ArrayList getConfigParameters()

addConfigParameter

public void addConfigParameter(ConfigParameter parameter)

getDescription

public java.lang.String getDescription()

setDescription

public void setDescription(java.lang.String description)

ownedBy

public boolean ownedBy(Player p)

getOwnerID

public java.lang.String getOwnerID()

setOwnerID

public void setOwnerID(java.lang.String ownerID)

getProposalID

public java.lang.String getProposalID()

setProposalID

public void setProposalID(java.lang.String id)

getEconCost

public float getEconCost()

getSocialCost

public float getSocialCost()

getDebriefingText

public java.lang.String getDebriefingText()
Get text for the debriefing turn. Text for the debriefing turn comes from one of the following sources:

The value of these attributes are assumed to be HTML fragments, which means that there may be escaped HTML in them.

Returns:
text suitable for the debriefing stage.

getLegendIcons

public java.util.Set getLegendIcons()

getMapIcons

public java.util.Set getMapIcons()

calculateCosts

public void calculateCosts()

configure

public void configure(ConfigParameter c,
                      boolean val)

configure

public void configure(ConfigParameter c,
                      int index)

configure

public void configure(ConfigParameter c,
                      java.lang.String val)

getConfigSum

public java.lang.String getConfigSum()

configureFromSum

public void configureFromSum(java.lang.String configSum)

enumerateConfigurations

public java.util.List enumerateConfigurations()

getFamily

public java.lang.String getFamily()

setFamily

public void setFamily(java.lang.String family)

getAbbrev

public java.lang.String getAbbrev()
Returns an string containing an abbreviated description of the proposal's configuration details.


isDuplicate

public boolean isDuplicate(Proposal p)
Determines whether this proposal is a duplicate of the proposal given as an argument. Two proposals are duplicates of one another if they have the same family, the same set of configParameters (implied by same family), and all the configParameter values are set the same.

Returns:
true if the proposals duplicate one another; false otherwise.

enact

public void enact(GameRoot root)
Enable the proposal. This method is called immediately after this proposal is passed. It should set any game state that is implied by passing the proposal (such as lowering the remaining budget).


enact

public void enact(GameRoot root,
                  java.util.Random rng)
This is stub method to be overridden by subclasses; in Proposal, it just calls enact(root).


getPlayerOpinion

public java.lang.String getPlayerOpinion(Player player)
Gets a player's opinion about the this proposal. A player's opinion is one of the constants SUPPORT (in favor), or OPPOSE (against). If the vote is any other string, that string implies a "depends" opinion about the proposal, and the string should contain some descriptive text which describes what it depends upon.

Parameters:
player - Player whose opinion should be queried
Returns:
SUPPORT, OPPOSE, or some other descriptive text

getPlayerOpinion

public java.lang.String getPlayerOpinion(Player player,
                                         java.lang.String defaultValue)

setPlayerOpinion

public void setPlayerOpinion(Player player,
                             java.lang.String pref)
Sets a player's opinion about the this proposal. A player's opinion is one of the constants SUPPORT (in favor), or OPPOSE (against). If the vote is any other string, that string implies a "depends" opinion about the proposal, and the string should contain some descriptive text which describes what it depends upon.

Parameters:
player - Player whose opinion should be queried
pref - SUPPORT, OPPOSE, or some other descriptive text

duplicate

public SimObject duplicate()
Duplicates the Proposal by calling SimObject.duplicate(), then iterating over the properties and removing all the instances of "proposalSupportFor" (that is, opinions).

Overrides:
duplicate in class SimObject
Returns:
a SimObject that is actually a Proposal.

getPlayerVotesFor

public int getPlayerVotesFor(Player player)
Returns the player's vote on this proposal. A positive vote indicates support, a negative vote indicates opposition. This method returns the total support or opposition, not just the last vote cast.

Parameters:
player - Player whose support should be queried
Returns:
the total support (positive) or opposition (negative) to this proposal.

getPlayerVotesAgainst

public int getPlayerVotesAgainst(Player player)

castVote

public void castVote(java.lang.String playerID,
                     int newVote)
Casts a vote for (or against) this proposal. A positive vote indicates support, a negative vote indicates opposition. This increments or decrements the current vote tally for this player.

Parameters:
playerID - Player casting a vote
newVote - vote to be added to the tally

getVotesFor

public int getVotesFor()

getVotesAgainst

public int getVotesAgainst()

resetVoteTally

public void resetVoteTally()
Resets the vote tally for this proposal to zero. At the beginning of voting, this should be called to make sure there aren't any extra votes for this proposal.


getVoteTally

public int getVoteTally()
Returns the "global" vote tally for this proposal. If the tally is positive, the vote passes, otherwise it fails.

Returns:
the net support from voting on this proposal

getStatus

public java.lang.String getStatus()

setStatus

public void setStatus(java.lang.String status)

compareTo

public int compareTo(java.lang.Object o)
Specified by:
compareTo in interface java.lang.Comparable

main

public static void main(java.lang.String[] args)