5 * $Id: FrenzyModel.java,v 1.2 2008/04/30 04:11:55 rmh3093 Exp $
8 * $Log: FrenzyModel.java,v $
9 * Revision 1.2 2008/04/30 04:11:55 rmh3093
10 * break out Player and Enemy class, other changes
12 * Revision 1.1 2008/04/26 15:46:05 rmh3093
18 Copyright (c) 2008, Ryan M. Hope
21 Redistribution and use in source and binary forms, with or without modification,
22 are permitted provided that the following conditions are met:
24 * Redistributions of source code must retain the above copyright notice,
25 this list of conditions and the following disclaimer.
26 * Redistributions in binary form must reproduce the above copyright notice,
27 this list of conditions and the following disclaimer in the documentation
28 and/or other materials provided with the distribution.
29 * Neither the name of the project nor the names of its contributors may be
30 used to endorse or promote products derived from this software without
31 specific prior written permission.
33 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
34 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
35 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
36 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
37 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
38 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
39 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
40 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
41 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
42 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
45 import java
.util
.TreeMap
;
48 * Stores all the data and important generic aspects of the game Frenzy
52 public class FrenzyModel
{
54 // Random number generator
55 private BetterRandom betterRandom
;
57 // The number of rows and columns for the current game
61 public FrenzyPlayer player
;
64 public TreeMap
<String
, FrenzyEnemy
> enimies
=
65 new TreeMap
<String
, FrenzyEnemy
>();
67 // Valid 'printable' ASCII characters start at 1 and go to 254, if you
68 // subtract the non-printing characters, there are 187 unique characters
69 public static final int MAX_ENIMES
= 187;
71 // The number of active enemies
72 protected int enemyCount
= 0;
74 // The interval in ms to spawn enemies
75 int enemySpawnInterval
= 3000;
77 // The interval in ms to spawn enemies
78 int enemyMoveInterval
= 600;
80 // The possible occupants of a board square
81 static enum OCCUPANT
{NONE
,PLAYER
,ENEMY
};
84 public boolean gamestate
= false;
87 * Create a new Frenzy model
89 * @param boardSize number of rows and columns
91 FrenzyModel(int boardSize
, BetterRandom betterRandom
) {
92 this.betterRandom
= betterRandom
;
93 this.boardsize
= boardSize
;
97 * Returns the number of rows and columns for the current game
99 * @return number of rows and columns
105 protected synchronized void decreaseEnemyCount() {
109 protected synchronized void increaseEnemyCount() {