gifflen / Javademic

An educational clone of the board game Pandemic by Zman Games
1 stars 3 forks source link

Location Outbreak Behavior #12

Closed BrianJerardi closed 12 years ago

BrianJerardi commented 12 years ago

Currently locations are set up to be able to outbreak only once per turn, but my interpretation of the rules is they can outbreak more than once per turn just only once per reaction. I'd prefer if the testing could be done in the location itself. Although if that is not possible we may have to have it done in the infection cards. Either way it probably shouldn't happen in board, unless I'm missing something.

drinne commented 12 years ago

Outbreaks happen 2 ways

Infection places a new disease cube where there are already three of that disease on the location - that triggers outbreak

Epidemic can add an infection cycle to an existing turn to trigger an outbreak so it's still using infection as the trigger

An outreak can trigger a chain reaction outbreak so multiple oubreak cycles can happen on a single turn. I don't think the physics of the way outbreaks work can support mulitple outbreaks of a single disease at a single location but in a long game a single location might be subject to multiple outbreaks of multiple diseases in a single turn unless Epidemic is triggerd - if there is a turn constraint we might be able to just write an override in the epdidemic methotd. Alternatvely outbreak can simply trigger on the location based on disease cube count invoking outbreak without making it turn based it could be a state based action.

The other place to put the outbreak is when it checks the disease count when you create the boolean because the diseaseCount is full you return the boolean but inside the add.disease method you trigger the outbreak - then it's no longer turn dependent ( code as it stands below). If someone wants to try it:

public boolean addDisease(Disease disease) { if (position >= diseases.length) { return false; }

    diseases[position++] = disease;
    return true;
}

/**
 * Adds a disease with initialName, initialImgLoc, 
 *  and initialCount to this collection
 * @precondition
 *  diseases is not full
 * @param initialName
 *  The initial name of the disease to add
 * @param initialImgLoc
 *  The initial image location of the disease to add
 * @param initialCount
 *  The initial count of the disease to add
 * @postcondition
 *  disease has been added to this collection
 *  position has been incremented
 * @return 
 *  true if disease was added
 *  false if disease was NOT added because diseases was full
 */
public boolean addDisease
        (String initialName, String initialImgLoc, int initialCount)
{
    return addDisease
            (new Disease(initialName, initialImgLoc, initialCount));
}
BrianJerardi commented 12 years ago

I'm not sure I entirely follow you, but one disease at one location can outbreak multiple times in one turn. For example an infection card causes an outbreak at location 1 which brings the count of that colors cubes at location 2 to 3. Then an infection card causes an outbreak at location 2 which triggers another outbreak at location 1.

So we need to reset outBreakThisReaction after infections are complete, and after an epidemic is complete.

I don't think anything needs to go in the Disease classes. And I don't really understand what you are getting at with that, because the above code you posted is adding new Disease to the Diseases Collection class. It is checking if the collection is full, returning false if it is because it can't add any more diseases to the collection.

drinne commented 12 years ago

Right but when I was going through the code for diseases and locations I didn't see anything that triggered an outbreak as a method - going through it more carefully to respond I see where it is in Locations.

I just started with netbeans yesterday - so I'm still adjusting to reading it . . .but now I'm confused. I see where oubreaks sits now but where is the constraint that limits it to one turn?

private void outbreak(Disease incDisease){ System.out.println("OUTBREAK AT " + locationName + " of " + incDisease.getName()); this.outBreakThisReaction = true; for (Location connection: connections.values()){ connection.infect(incDisease); } }

BrianJerardi commented 12 years ago

It is in the infect method, because it will only ever be triggered when adding more than 3 cubes. That is where it checks to see if outBreakThisReaction is false, and if it is it causes an outbreak. The way it is coded currently is that outBreakThisReaction is set to true for the location after an outbreak, and it is reset from the Board using the cleanUpOutBreaks method.

Now that I'm looking at it, my initial problem might be a non-issue. I still haven't completely gone over the Board class. I thought it was cleaning up outbreaks after a turn, but now it looks like it might be doing it after every draw of an infection card. I think the original name of the variable messed me up, because it was called outBreakThisTurn.

I think the only issues now are that it isn't tracked per disease only per location, and they need to be cleaned up after an epidemic as well.

drinne commented 12 years ago

OK that makes way more sense now - because I saw the infect method checked agains three cubes so I figured every time it was used the potential to infect and trigger the outbreak was in there. When I was looking for that trigger the first time I didn't see it properly so I was focused on the outbreak boolean and was looking for the wrong things. So I thought it was a rules question which is why I answered the way I did.

Or maybe I'm not seeing the right code - I see something called oubreakThisReaction but I also found out that I didn't have all the files in the project open the way I thought I did. I downloaded the testing branch last night at 11.

Maybe we should changed the name of the variable ?

drinne commented 12 years ago

Ok nevermind I found the comment on your update from yesterday - I was reading the changed variable. I think this is resolved and you've alread corrected the possibility of confusion on the contraint so I'm going to close the issue - sorry for distracting you!