diff --git a/README.md b/README.md index e569c92..a3e6d83 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,9 @@ # Project RPG -*Version 1.0* +*Version 2.0* Welcome to Project RPG, an innovative RPG envisioned by Sinho Chewi and Alexander Tran. Play as a character in a magical academy who gains increasingly powerful spells through courses. -The game is currently a work-in-progress, with a text-based interface. - # Instructions ## Compilation diff --git a/src/project_rpg/Gui.java b/src/project_rpg/Gui.java index d567be8..43e0706 100644 --- a/src/project_rpg/Gui.java +++ b/src/project_rpg/Gui.java @@ -496,8 +496,8 @@ public class ChangeSkillListener implements ActionListener { /** Constructor that takes in battle skill NUMBER. */ public ChangeSkillListener(int number, JComboBox box) { - number = number - 1; - box = box; + this.number = number - 1; + this.box = box; } @Override diff --git a/src/project_rpg/SkillToken.java b/src/project_rpg/SkillToken.java index c48b578..630a145 100644 --- a/src/project_rpg/SkillToken.java +++ b/src/project_rpg/SkillToken.java @@ -48,6 +48,37 @@ private void earthAttack() { } } } + + /** Controls behavior for spells with lightning attacks. */ + private void lightningAttack() { + int monsterCount = 3; + while (true) { + if (monsterCount == 0) { + disappear(); + return; + } + if (isReadyForAction(250)) { + int newX = getX() + dirX; + int newY = getY() + dirY; + if (!getGrid().inBounds(newX, newY)) { + disappear(); + return; + } else if (getGrid().monsterAt(newX, newY)) { + int damage = skill.attack(); + getGrid().reduceHealth(newX, newY, damage, skill.getName()); + monsterCount = monsterCount - 1; + move(newX + dirX, newY + dirY); + takeAction(); + } else if (getGrid().getTokenAt(newX, newY) != null) { + disappear(); + return; + } else { + move(newX, newY); + takeAction(); + } + } + } + } /** Controls behavior for spells that don't attack. */ private void nothing() { @@ -56,18 +87,19 @@ private void nothing() { @Override public void run() { + getGrid().getPlayer().reduceMana(skill.getCost()); if (skill.getBehavior().equals("straightLine")) { - getGrid().getPlayer().reduceMana(skill.getCost()); straightLine(); } if (skill.getBehavior().equals("nothing")) { - getGrid().getPlayer().reduceMana(skill.getCost()); nothing(); } if (skill.getBehavior().equals("earthAttack")) { - getGrid().getPlayer().reduceMana(skill.getCost()); earthAttack(); } + if (skill.getBehavior().equals("windAttack")) { + windAttack(); + } } /** Controls behavior for spells that move in a straight line. */ @@ -95,6 +127,35 @@ private void straightLine() { } } + /** Controls behavior for spells with wind elements. */ + private void windAttack() { + while (true) { + if (isReadyForAction(250)) { + int newX = getX() + dirX; + int newY = getY() + dirY; + if (!getGrid().inBounds(newX, newY)) { + disappear(); + return; + } else if (getGrid().monsterAt(newX, newY)) { + int damage = skill.attack(); + getGrid().reduceHealth(newX, newY, damage, skill.getName()); + int knockX = newX + 3 * dirX; + int knockY = newY + 3 * dirY; + Token monsterToken = getGrid().getTokenAt(newX, newY); + monsterToken.forceMove(knockX, knockY); + disappear(); + return; + } else if (getGrid().getTokenAt(newX, newY) != null) { + disappear(); + return; + } else { + move(newX, newY); + takeAction(); + } + } + } + } + /** The direction of movement of the spell. */ private int dirX; private int dirY; diff --git a/src/project_rpg/Token.java b/src/project_rpg/Token.java index a9e0910..20fc46a 100644 --- a/src/project_rpg/Token.java +++ b/src/project_rpg/Token.java @@ -65,6 +65,18 @@ protected void down() { move(positionX, positionY + 1); orientation = BattleGrid.RIGHT_ANGLE; } + + /** Makes me move forcibly to (NEWX, NEWY). */ + protected void forceMove(int newX, int newY) { + if (grid.valid(newX, newY)) { + grid.addTokenAt(null, positionX, positionY); + grid.addTokenAt(this, newX, newY); + positionX = newX; + positionY = newY; + lastMovement = System.currentTimeMillis(); + grid.repaint(); + } + } /** Returns the BattleGrid in which the Token is located. */ protected BattleGrid getGrid() { diff --git a/src/project_rpg/database/courses/introduction_to_lightning_magic.json b/src/project_rpg/database/courses/introduction_to_lightning_magic.json index c8385b1..0e02349 100644 --- a/src/project_rpg/database/courses/introduction_to_lightning_magic.json +++ b/src/project_rpg/database/courses/introduction_to_lightning_magic.json @@ -1,55 +1,55 @@ { "courseTitle": "Introduction to Lightning Magic", - "description": "Covers the basics of handling Lightning magic, culminating in the production of a Lightning Ball.", - "skill": "lightning_ball", + "description": "Covers the basics of handling Lightning magic, culminating in the production of a Lightning Bolt.", + "skill": "lightning_bolt", "1": { - "name": "Lightning Ball Basics I", - "description": "Learn how to handle a Lightning Ball.", + "name": "Lightning Bolt Basics I", + "description": "Learn how to handle a Lightning Bolt.", "dungeon": "test_dungeon" }, "2": { - "name": "Lightning Ball Basics II", - "description": "Learn how to handle a Lightning Ball.", + "name": "Lightning Bolt Basics II", + "description": "Learn how to handle a Lightning Bolt.", "dungeon": "test_dungeon" }, "3": { - "name": "Lightning Ball Basics III", - "description": "Learn how to handle a Lightning Ball.", + "name": "Lightning Bolt Basics III", + "description": "Learn how to handle a Lightning Bolt.", "dungeon": "test_dungeon" }, "4": { - "name": "Lightning Ball Basics IV", - "description": "Learn how to handle a Lightning Ball.", + "name": "Lightning Bolt Basics IV", + "description": "Learn how to handle a Lightning Bolt.", "dungeon": "test_dungeon" }, "5": { - "name": "Lightning Ball Basics: Midterm", - "description": "Learn how to handle a Lightning Ball.", + "name": "Lightning Bolt Basics: Midterm", + "description": "Learn how to handle a Lightning Bolt.", "dungeon": "test_dungeon" }, "6": { - "name": "Lightning Ball Basics VI", - "description": "Learn how to handle a Lightning Ball.", + "name": "Lightning Bolt Basics VI", + "description": "Learn how to handle a Lightning Bolt.", "dungeon": "test_dungeon" }, "7": { - "name": "Lightning Ball Basics VII", - "description": "Learn how to handle a Lightning Ball.", + "name": "Lightning Bolt Basics VII", + "description": "Learn how to handle a Lightning Bolt.", "dungeon": "test_dungeon" }, "8": { - "name": "Lightning Ball Basics VIII", - "description": "Learn how to handle a Lightning Ball.", + "name": "Lightning Bolt Basics VIII", + "description": "Learn how to handle a Lightning Bolt.", "dungeon": "test_dungeon" }, "9": { - "name": "Lightning Ball Basics IX", - "description": "Learn how to handle a Lightning Ball.", + "name": "Lightning Bolt Basics IX", + "description": "Learn how to handle a Lightning Bolt.", "dungeon": "test_dungeon" }, "10": { - "name": "Lightning Ball Basics X", - "description": "Learn how to handle a Lightning Ball.", + "name": "Lightning Bolt Basics X", + "description": "Learn how to handle a Lightning Bolt.", "dungeon": "test_dungeon" } } diff --git a/src/project_rpg/database/skills/gust.json b/src/project_rpg/database/skills/gust.json index 301120d..2e491d5 100644 --- a/src/project_rpg/database/skills/gust.json +++ b/src/project_rpg/database/skills/gust.json @@ -1,10 +1,10 @@ { "baseDamage": 10, "baseMp": 3, - "behavior": "straightLine", + "behavior": "windAttack", "cooldown": 1000, "description": "A gust of wind!", - "image": "Fireball", + "image": "Gust", "name": "Gust" } diff --git a/src/project_rpg/database/skills/lightning_ball.json b/src/project_rpg/database/skills/lightning_ball.json deleted file mode 100644 index ffb176d..0000000 --- a/src/project_rpg/database/skills/lightning_ball.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "baseDamage": 10, - "baseMp": 3, - "behavior": "straightLine", - "cooldown": 1000, - "description": "A ball of lightning!", - "image": "Fireball", - "name": "Lightning Ball" -} - diff --git a/src/project_rpg/database/skills/lightning_bolt.json b/src/project_rpg/database/skills/lightning_bolt.json new file mode 100644 index 0000000..4d0c217 --- /dev/null +++ b/src/project_rpg/database/skills/lightning_bolt.json @@ -0,0 +1,10 @@ +{ + "baseDamage": 10, + "baseMp": 3, + "behavior": "lightningAttack", + "cooldown": 1000, + "description": "A bolt of lightning!", + "image": "LightningBolt", + "name": "Lightning bolt" +} + diff --git a/src/project_rpg/resources/Gust.png b/src/project_rpg/resources/Gust.png new file mode 100644 index 0000000..5ad128f Binary files /dev/null and b/src/project_rpg/resources/Gust.png differ diff --git a/src/project_rpg/resources/LightningBolt.png b/src/project_rpg/resources/LightningBolt.png new file mode 100644 index 0000000..187e6d5 Binary files /dev/null and b/src/project_rpg/resources/LightningBolt.png differ