diff options
author | Starla Insigna <hatkirby@fourisland.com> | 2012-06-05 18:31:40 -0400 |
---|---|---|
committer | Starla Insigna <hatkirby@fourisland.com> | 2012-06-05 18:31:40 -0400 |
commit | 926db95ee63a5f85a4954a55f27a28f76c6bb152 (patch) | |
tree | c91b8943323b57dfa6f390dc885fbbd21f37ae50 /src/com | |
parent | 5d3e3ec4224e93307d69442ab844a220b8208ccd (diff) | |
download | frigidearth-926db95ee63a5f85a4954a55f27a28f76c6bb152.tar.gz frigidearth-926db95ee63a5f85a4954a55f27a28f76c6bb152.tar.bz2 frigidearth-926db95ee63a5f85a4954a55f27a28f76c6bb152.zip |
Gave clothing attack and defense values
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/fourisland/frigidearth/Game.java | 11 | ||||
-rw-r--r-- | src/com/fourisland/frigidearth/Item.java | 25 | ||||
-rw-r--r-- | src/com/fourisland/frigidearth/MapViewGameState.java | 6 | ||||
-rw-r--r-- | src/com/fourisland/frigidearth/mobs/Spider.java | 2 |
4 files changed, 39 insertions, 5 deletions
diff --git a/src/com/fourisland/frigidearth/Game.java b/src/com/fourisland/frigidearth/Game.java index fdd4110..621148c 100644 --- a/src/com/fourisland/frigidearth/Game.java +++ b/src/com/fourisland/frigidearth/Game.java | |||
@@ -15,7 +15,6 @@ public class Game | |||
15 | { | 15 | { |
16 | public int health = 15; | 16 | public int health = 15; |
17 | public int maxHealth = 15; | 17 | public int maxHealth = 15; |
18 | public int defense = 0; | ||
19 | public int level = 1; | 18 | public int level = 1; |
20 | public int experience = 0; | 19 | public int experience = 0; |
21 | public List<Item> inventory = new ArrayList<Item>(); | 20 | public List<Item> inventory = new ArrayList<Item>(); |
@@ -147,4 +146,14 @@ public class Game | |||
147 | 146 | ||
148 | return true; | 147 | return true; |
149 | } | 148 | } |
149 | |||
150 | public int getAttackPower() | ||
151 | { | ||
152 | return (int) (Math.floor(Math.sqrt(level)) + (sword == null ? 0 : sword.getAttackPower())); | ||
153 | } | ||
154 | |||
155 | public int getDefense() | ||
156 | { | ||
157 | return (helmet == null ? 0 : helmet.getDefense()) + (shield == null ? 0 : shield.getDefense()) + (shoes == null ? 0 : shoes.getDefense()); | ||
158 | } | ||
150 | } | 159 | } |
diff --git a/src/com/fourisland/frigidearth/Item.java b/src/com/fourisland/frigidearth/Item.java index 4527cbe..63f2f02 100644 --- a/src/com/fourisland/frigidearth/Item.java +++ b/src/com/fourisland/frigidearth/Item.java | |||
@@ -70,6 +70,11 @@ public enum Item | |||
70 | { | 70 | { |
71 | return ItemType.Helmet; | 71 | return ItemType.Helmet; |
72 | } | 72 | } |
73 | |||
74 | public int getDefense() | ||
75 | { | ||
76 | return 1; | ||
77 | } | ||
73 | }, | 78 | }, |
74 | WoodenSword { | 79 | WoodenSword { |
75 | public String getItemName() | 80 | public String getItemName() |
@@ -91,6 +96,11 @@ public enum Item | |||
91 | { | 96 | { |
92 | return ItemType.Sword; | 97 | return ItemType.Sword; |
93 | } | 98 | } |
99 | |||
100 | public int getAttackPower() | ||
101 | { | ||
102 | return 1; | ||
103 | } | ||
94 | }, | 104 | }, |
95 | WoodenShield { | 105 | WoodenShield { |
96 | public String getItemName() | 106 | public String getItemName() |
@@ -112,6 +122,11 @@ public enum Item | |||
112 | { | 122 | { |
113 | return ItemType.Shield; | 123 | return ItemType.Shield; |
114 | } | 124 | } |
125 | |||
126 | public int getDefense() | ||
127 | { | ||
128 | return 1; | ||
129 | } | ||
115 | }, | 130 | }, |
116 | RingOfRegeneration { | 131 | RingOfRegeneration { |
117 | public String getItemName() | 132 | public String getItemName() |
@@ -244,4 +259,14 @@ public enum Item | |||
244 | 259 | ||
245 | return null; | 260 | return null; |
246 | } | 261 | } |
262 | |||
263 | public int getAttackPower() | ||
264 | { | ||
265 | return 0; | ||
266 | } | ||
267 | |||
268 | public int getDefense() | ||
269 | { | ||
270 | return 0; | ||
271 | } | ||
247 | } | 272 | } |
diff --git a/src/com/fourisland/frigidearth/MapViewGameState.java b/src/com/fourisland/frigidearth/MapViewGameState.java index 30a2c93..07df1d6 100644 --- a/src/com/fourisland/frigidearth/MapViewGameState.java +++ b/src/com/fourisland/frigidearth/MapViewGameState.java | |||
@@ -761,7 +761,7 @@ public class MapViewGameState implements GameState | |||
761 | 761 | ||
762 | g.drawImage(SystemFont.getCharacter((char) 5, Color.GRAY), (healthText.length()+3)*TILE_WIDTH, 0, TILE_WIDTH, TILE_HEIGHT, null); | 762 | g.drawImage(SystemFont.getCharacter((char) 5, Color.GRAY), (healthText.length()+3)*TILE_WIDTH, 0, TILE_WIDTH, TILE_HEIGHT, null); |
763 | int b = healthText.length()+4; | 763 | int b = healthText.length()+4; |
764 | String defenseText = Integer.toString(Main.currentGame.defense); | 764 | String defenseText = Integer.toString(Main.currentGame.getDefense()); |
765 | for (int i=0; i<defenseText.length(); i++) | 765 | for (int i=0; i<defenseText.length(); i++) |
766 | { | 766 | { |
767 | g.drawImage(SystemFont.getCharacter(defenseText.charAt(i), Color.WHITE), (i+b)*TILE_WIDTH, 0, TILE_WIDTH, TILE_HEIGHT, null); | 767 | g.drawImage(SystemFont.getCharacter(defenseText.charAt(i), Color.WHITE), (i+b)*TILE_WIDTH, 0, TILE_WIDTH, TILE_HEIGHT, null); |
@@ -808,7 +808,7 @@ public class MapViewGameState implements GameState | |||
808 | if (mob.getPosition().equals(to)) | 808 | if (mob.getPosition().equals(to)) |
809 | { | 809 | { |
810 | printMessage("You hit the " + mob.getName().toLowerCase()); | 810 | printMessage("You hit the " + mob.getName().toLowerCase()); |
811 | mob.health -= (int) (Math.floor(Math.sqrt(Main.currentGame.level))); | 811 | mob.health -= Main.currentGame.getAttackPower(); |
812 | 812 | ||
813 | if (mob.health <= 0) | 813 | if (mob.health <= 0) |
814 | { | 814 | { |
@@ -942,7 +942,7 @@ public class MapViewGameState implements GameState | |||
942 | if (arePointsAdjacent(playerx, playery, mob.x, mob.y, false)) | 942 | if (arePointsAdjacent(playerx, playery, mob.x, mob.y, false)) |
943 | { | 943 | { |
944 | // Attack! | 944 | // Attack! |
945 | Main.currentGame.health -= Math.max(mob.getAttackPower() - Main.currentGame.defense, 0); | 945 | Main.currentGame.health -= Math.max(mob.getAttackPower() - Functions.random(0,Main.currentGame.getDefense()), 0); |
946 | printMessage(mob.getBattleMessage()); | 946 | printMessage(mob.getBattleMessage()); |
947 | } else { | 947 | } else { |
948 | List<Direction> path = findPath(mob.getPosition(), new Point(playerx, playery)); | 948 | List<Direction> path = findPath(mob.getPosition(), new Point(playerx, playery)); |
diff --git a/src/com/fourisland/frigidearth/mobs/Spider.java b/src/com/fourisland/frigidearth/mobs/Spider.java index ac3eb9d..a3ee637 100644 --- a/src/com/fourisland/frigidearth/mobs/Spider.java +++ b/src/com/fourisland/frigidearth/mobs/Spider.java | |||
@@ -44,7 +44,7 @@ public class Spider extends Mob | |||
44 | 44 | ||
45 | public int getAttackPower() | 45 | public int getAttackPower() |
46 | { | 46 | { |
47 | return 1; | 47 | return Functions.rollDice(1,2); |
48 | } | 48 | } |
49 | 49 | ||
50 | public int getBaseExperience() | 50 | public int getBaseExperience() |