Skip to content

Commit

Permalink
Started describing the Attributes class.
Browse files Browse the repository at this point in the history
  • Loading branch information
darozak committed May 26, 2024
1 parent b672ede commit ca70ffc
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 34 deletions.
30 changes: 15 additions & 15 deletions Code/dist/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ class Game {
robot.adjustedStats.copy(robot.baseStats);
for (var i = 0; i < robot.items.length; i++) {
if (robot.items[i].isEquipped) {
robot.adjustedStats.add(robot.items[i].effects);
robot.adjustedStats.add(robot.items[i].attributes);
}
}
}
Expand All @@ -533,17 +533,17 @@ class Game {
takeDamage(robot, damage) {
for (var i = 0; i < robot.items.length; i++) {
if (robot.items[i].isEquipped) {
if (damage <= robot.items[i].effects.HPs) {
if (damage <= robot.items[i].attributes.HPs) {
// Item absorbes all remaining damage.
robot.items[i].effects.HPs -= damage;
robot.items[i].attributes.HPs -= damage;
robot.adjustedStats.HPs -= damage;
damage = 0;
}
else {
// Item only absorbes some of the remaining damage.
damage -= robot.items[i].effects.HPs;
robot.adjustedStats.HPs -= robot.items[i].effects.HPs;
robot.items[i].effects.HPs = 0;
damage -= robot.items[i].attributes.HPs;
robot.adjustedStats.HPs -= robot.items[i].attributes.HPs;
robot.items[i].attributes.HPs = 0;
}
}
}
Expand All @@ -563,16 +563,16 @@ class Game {
// Only take power from active items.
if (robot.items[i].isEquipped) {
// Drain required power from item if there is enough.
if (amount <= robot.items[i].effects.power) {
robot.items[i].effects.power -= amount;
if (amount <= robot.items[i].attributes.power) {
robot.items[i].attributes.power -= amount;
robot.adjustedStats.power -= amount;
amount = 0;
// Otherwise drain what is available from that item.
}
else {
amount -= robot.items[i].effects.power;
robot.adjustedStats.power -= robot.items[i].effects.power;
robot.items[i].effects.power = 0;
amount -= robot.items[i].attributes.power;
robot.adjustedStats.power -= robot.items[i].attributes.power;
robot.items[i].attributes.power = 0;
}
}
}
Expand All @@ -581,13 +581,13 @@ class Game {
}
addPower(robot, amount) {
for (var i = 0; i < robot.items.length; i++) {
if (amount + robot.items[i].effects.power <= robot.items[i].effects.maxPower) {
robot.items[i].effects.power += amount;
if (amount + robot.items[i].attributes.power <= robot.items[i].attributes.maxPower) {
robot.items[i].attributes.power += amount;
amount = 0;
}
else {
amount -= robot.items[i].effects.maxPower - robot.items[i].effects.power;
robot.items[i].effects.power = robot.items[i].effects.maxPower;
amount -= robot.items[i].attributes.maxPower - robot.items[i].attributes.power;
robot.items[i].attributes.power = robot.items[i].attributes.maxPower;
}
}
return (amount == 0);
Expand Down
4 changes: 2 additions & 2 deletions Code/dist/hardware.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"use strict";
class Item {
name;
effects;
attributes;
timeToEquip = 10;
isEquipped = false;
constructor(name, effects) {
this.name = name;
this.effects = effects;
this.attributes = effects;
}
}
class Attributes {
Expand Down
30 changes: 15 additions & 15 deletions Code/src/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ class Game {

for(var i = 0; i < robot.items.length; i ++) {
if(robot.items[i].isEquipped) {
robot.adjustedStats.add(robot.items[i].effects);
robot.adjustedStats.add(robot.items[i].attributes);
}
}

Expand All @@ -699,18 +699,18 @@ class Game {
takeDamage(robot: RobotData, damage: number){
for(var i = 0; i < robot.items.length; i ++) {
if(robot.items[i].isEquipped) {
if(damage <= robot.items[i].effects.HPs) {
if(damage <= robot.items[i].attributes.HPs) {

// Item absorbes all remaining damage.
robot.items[i].effects.HPs -= damage;
robot.items[i].attributes.HPs -= damage;
robot.adjustedStats.HPs -= damage;
damage = 0;
} else {

// Item only absorbes some of the remaining damage.
damage -= robot.items[i].effects.HPs;
robot.adjustedStats.HPs -= robot.items[i].effects.HPs;
robot.items[i].effects.HPs = 0;
damage -= robot.items[i].attributes.HPs;
robot.adjustedStats.HPs -= robot.items[i].attributes.HPs;
robot.items[i].attributes.HPs = 0;
}
}
}
Expand All @@ -735,16 +735,16 @@ class Game {
if(robot.items[i].isEquipped) {

// Drain required power from item if there is enough.
if(amount <= robot.items[i].effects.power) {
robot.items[i].effects.power -= amount;
if(amount <= robot.items[i].attributes.power) {
robot.items[i].attributes.power -= amount;
robot.adjustedStats.power -= amount;
amount = 0;

// Otherwise drain what is available from that item.
} else {
amount -= robot.items[i].effects.power;
robot.adjustedStats.power -= robot.items[i].effects.power;
robot.items[i].effects.power = 0;
amount -= robot.items[i].attributes.power;
robot.adjustedStats.power -= robot.items[i].attributes.power;
robot.items[i].attributes.power = 0;
}
}
}
Expand All @@ -756,12 +756,12 @@ class Game {
addPower(robot: RobotData, amount: number){

for(var i = 0; i < robot.items.length; i ++) {
if(amount + robot.items[i].effects.power <= robot.items[i].effects.maxPower) {
robot.items[i].effects.power += amount;
if(amount + robot.items[i].attributes.power <= robot.items[i].attributes.maxPower) {
robot.items[i].attributes.power += amount;
amount = 0;
} else {
amount -= robot.items[i].effects.maxPower - robot.items[i].effects.power;
robot.items[i].effects.power = robot.items[i].effects.maxPower;
amount -= robot.items[i].attributes.maxPower - robot.items[i].attributes.power;
robot.items[i].attributes.power = robot.items[i].attributes.maxPower;
}
}
return (amount == 0);
Expand Down
4 changes: 2 additions & 2 deletions Code/src/hardware.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@

class Item {
name: string;
effects: Attributes;
attributes: Attributes;
timeToEquip: number = 10;
isEquipped: boolean = false;

constructor(name: string, effects: Attributes) {
this.name = name;
this.effects = effects;
this.attributes = effects;
}
}

Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ The item class is used to describe to properties and status of all in-game items
| timeToEquip | number | This is the time required to equip an item for use. |

## Attributes Class
Both robots and items have attributes. Generally, a robot's attributes sum all the attributes of it's equipped items.

| Variable | Type | Description |
| -------- | ---- | ----------- |
| credits | number | The total value of the robot or item. The robot with the greatest value at the end of the game wins. |
| HPs | number | The total amount of hitpoints posessed by a robot or provided by an intem. |
| moveCost | number | The total power cost of a move action. |
| moveTime | number | The amount of time it takes for a robot to complete a move action. |



## Action Classes
Advolition has eight pre-defined Action class extensions that the robot can use to describe it's next move. These classes are as follows:
Expand Down

0 comments on commit ca70ffc

Please sign in to comment.