Skip to content

Commit

Permalink
feat(combat): add auto-combat button
Browse files Browse the repository at this point in the history
Feat/auto combat
  • Loading branch information
justindujardin authored Feb 22, 2024
2 parents 632d97f + 08e85b1 commit 15df6db
Show file tree
Hide file tree
Showing 30 changed files with 690 additions and 110 deletions.
260 changes: 240 additions & 20 deletions angular-rpg.tiled-session
Original file line number Diff line number Diff line change
@@ -1,38 +1,258 @@
{
"activeFile": "src/assets/maps/town.tmx",
"activeFile": "src/assets/maps/wilderness.tmx",
"expandedProjectPaths": [
".",
"src/assets",
"src/art/sprites/characters/magic",
"src/tiled/createdialogtool",
"src",
"src/assets/maps/templates",
"src/art/sprites/characters/punch",
"src/assets/maps",
"src/art/sprites",
"src/tiled/createdialogtool",
".",
"src/art",
"src/tiled",
"src/assets/maps/tiles",
"src/art/sprites/characters/magic",
"src/art/sprites",
"src/art/sprites/characters/punch",
"src/assets/test",
"src/assets"
"src/art",
"src/assets/maps/templates",
"src/assets/maps/tiles"
],
"file.lastUsedOpenFilter": "All Files (*)",
"fileStates": {},
"fileStates": {
"src/assets/maps/castle.tmx": {
"expandedObjectLayers": [
2
],
"scale": 4,
"selectedLayer": 1,
"viewCenter": {
"x": 263.875,
"y": 135.875
}
},
"src/assets/maps/combat.tmx": {
"scale": 3.5070833333333336,
"selectedLayer": 9,
"viewCenter": {
"x": 239.94297255554233,
"y": 159.8194130925508
}
},
"src/assets/maps/crypt.tmx": {
"expandedObjectLayers": [
2,
3
],
"scale": 1.9243589743589742,
"selectedLayer": 1,
"viewCenter": {
"x": 199.80679546968688,
"y": 311.53231179213856
}
},
"src/assets/maps/fortress1.tmx": {
"expandedObjectLayers": [
2,
3
],
"scale": 2.420967741935484,
"selectedLayer": 1,
"viewCenter": {
"x": 223.6708860759494,
"y": 247.62824783477686
}
},
"src/assets/maps/fortress2.tmx": {
"expandedObjectLayers": [
4,
3
],
"scale": 3.002,
"selectedLayer": 2,
"viewCenter": {
"x": 199.70019986675553,
"y": 199.70019986675553
}
},
"src/assets/maps/isle.tmx": {
"expandedObjectLayers": [
2
],
"scale": 3.9499999999999997,
"selectedLayer": 1,
"viewCenter": {
"x": 199.873417721519,
"y": 151.7721518987342
}
},
"src/assets/maps/keep.tmx": {
"expandedObjectLayers": [
2
],
"scale": 3.2630434782608697,
"selectedLayer": 1,
"viewCenter": {
"x": 183.72418387741504,
"y": 183.72418387741504
}
},
"src/assets/maps/lair.tmx": {
"expandedObjectLayers": [
2
],
"scale": 1.4715686274509803,
"selectedLayer": 1,
"viewCenter": {
"x": 231.38574283810794,
"y": 407.3884077281813
}
},
"src/assets/maps/port.tmx": {
"expandedObjectLayers": [
2
],
"scale": 3.411363636363636,
"selectedLayer": 1,
"viewCenter": {
"x": 231.7255163224517,
"y": 175.73617588274487
}
},
"src/assets/maps/ruins.tmx": {
"expandedObjectLayers": [
3
],
"scale": 2.587931034482758,
"selectedLayer": 2,
"viewCenter": {
"x": 151.66555629580284,
"y": 231.6522318454364
}
},
"src/assets/maps/sewer.tmx": {
"expandedObjectLayers": [
2,
3
],
"scale": 1.8304878048780486,
"selectedLayer": 1,
"viewCenter": {
"x": 183.83077948034645,
"y": 327.508327781479
}
},
"src/assets/maps/tiles/creatures.tsx": {
"dynamicWrapping": true,
"scaleInDock": 1
},
"src/assets/maps/tiles/environment.tsx": {
"scaleInDock": 3
},
"src/assets/maps/tiles/objects.tsx": {
"dynamicWrapping": true,
"scaleInDock": 4,
"scaleInEditor": 11
},
"src/assets/maps/tower1.tmx": {
"expandedObjectLayers": [
2
],
"scale": 3.9499999999999997,
"selectedLayer": 1,
"viewCenter": {
"x": 183.92405063291142,
"y": 151.7721518987342
}
},
"src/assets/maps/tower2.tmx": {
"expandedObjectLayers": [
2
],
"scale": 3.9499999999999997,
"selectedLayer": 1,
"viewCenter": {
"x": 151.7721518987342,
"y": 151.7721518987342
}
},
"src/assets/maps/tower3.tmx": {
"expandedObjectLayers": [
2
],
"scale": 6.822727272727272,
"selectedLayer": 1,
"viewCenter": {
"x": 87.86808794137241,
"y": 87.86808794137244
}
},
"src/assets/maps/town.tmx": {
"expandedObjectLayers": [
2
],
"scale": 3.411363636363636,
"selectedLayer": 1,
"viewCenter": {
"x": 215.89606928714193,
"y": 175.73617588274487
}
},
"src/assets/maps/village.tmx": {
"expandedObjectLayers": [
2
],
"scale": 3.5738095238095235,
"selectedLayer": 1,
"viewCenter": {
"x": 111.7854763491006,
"y": 167.7481678880746
}
},
"src/assets/maps/wilderness.tmx": {
"expandedObjectLayers": [
6,
5
],
"scale": 1.5,
"selectedLayer": 3,
"viewCenter": {
"x": 1108.6666666666665,
"y": 290
}
}
},
"last.imagePath": "C:/Users/justi/Source/angular-rpg/src/art/sprites/objects",
"openFiles": [
"src/assets/maps/town.tmx"
"src/assets/maps/town.tmx",
"src/assets/maps/sewer.tmx",
"src/assets/maps/ruins.tmx",
"src/assets/maps/village.tmx",
"src/assets/maps/wilderness.tmx",
"src/assets/maps/castle.tmx",
"src/assets/maps/port.tmx",
"src/assets/maps/lair.tmx",
"src/assets/maps/fortress1.tmx",
"src/assets/maps/fortress2.tmx",
"src/assets/maps/combat.tmx",
"src/assets/maps/crypt.tmx",
"src/assets/maps/isle.tmx",
"src/assets/maps/keep.tmx",
"src/assets/maps/tower1.tmx",
"src/assets/maps/tower2.tmx",
"src/assets/maps/tower3.tmx"
],
"project": "angular-rpg.tiled-project",
"property.type": "string",
"recentFiles": [
"src/assets/maps/town.tmx",
"src/assets/maps/castle.tmx",
"src/assets/maps/sewer.tmx",
"src/assets/maps/ruins.tmx",
"src/assets/maps/village.tmx",
"src/assets/maps/tower3.tmx",
"src/assets/maps/tower2.tmx",
"src/assets/maps/tower1.tmx",
"src/assets/maps/keep.tmx",
"src/assets/maps/isle.tmx",
"src/assets/maps/crypt.tmx",
"src/assets/maps/combat.tmx",
"src/assets/maps/ruins.tmx",
"src/assets/maps/wilderness.tmx",
"src/assets/maps/lair.tmx",
"src/assets/maps/port.tmx",
"src/assets/maps/sewer.tmx",
"src/assets/maps/tower1.tmx",
"src/assets/maps/tower2.tmx"
"src/assets/maps/fortress2.tmx"
]
}
2 changes: 2 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ module.exports = function (config) {
// Don't hang rAF/timers when in background
"--disable-background-timer-throttling",
"--disable-backgrounding-occluded-windows",
// Don't play audio effects
"--mute-audio",
],
},
ChromeDebug: {
Expand Down
1 change: 0 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@
"@angular/compiler-cli": "^17.1.3",
"@babel/core": "^7.23.9",
"@compodoc/compodoc": "^1.1.19",
"@mapeditor/tiled-api": "^1.9.2",
"@semantic-release/changelog": "^6.0.0",
"@semantic-release/commit-analyzer": "^9.0.2",
"@semantic-release/git": "^10.0.0",
Expand Down
1 change: 0 additions & 1 deletion src/app/core/animator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export class Animator {
sourceAnims: any = null;

setAnimationSource(spriteName: string) {
console.log(`Sprite is ${spriteName}`);
this.sourceMeta = getSpriteMeta(spriteName);
if (this.sourceMeta) {
this.sourceAnims = this.sourceMeta.animations;
Expand Down
7 changes: 7 additions & 0 deletions src/app/core/point.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ describe('Point', () => {
});
});

describe('ceil', () => {
it('should truncate floating point by rounding up', () => {
const p1: Point = new Point(15.1, 15.1);
expect(p1.ceil()).toEqual(new Point(16, 16));
});
});

describe('round', () => {
it('should round up when decimal is greater than or equal to 0.5', () => {
const p1: Point = new Point(15.6, 15.6).round();
Expand Down
6 changes: 6 additions & 0 deletions src/app/core/point.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ export class Point implements IPoint {
return new Point(this.x, this.y);
}

ceil(): Point {
this.x = Math.ceil(this.x);
this.y = Math.ceil(this.y);
return this;
}

floor(): Point {
this.x = Math.floor(this.x);
this.y = Math.floor(this.y);
Expand Down
15 changes: 14 additions & 1 deletion src/app/core/state-machine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export interface IResumeCallback {
/** A state change description */
export interface IStateChange<T extends string> {
from: State<T> | null;
to: State<T>;
to: State<T> | null;
}

// Implementation
Expand All @@ -33,6 +33,19 @@ export class StateMachine<StateNames extends string> {
private _previousState: State<StateNames> | null = null;
private _pendingStates: [State<StateNames>, (result: boolean) => void][] = [];

/** Destroy the state machine, and exit any current state. */
async destroy() {
const state = this._currentState;
this._currentState = null;
this._pendingStates = [];
this._previousState = null;
this._transitioning = false;
if (state) {
this.onExitState$.emit({ from: state, to: null });
await state.exit(this);
}
}

addState(state: State<StateNames>): void {
this.states.push(state);
}
Expand Down
10 changes: 5 additions & 5 deletions src/app/models/game-data/magic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ export const MAGIC_DATA: ITemplateMagic[] = [
{
id: 'push',
type: 'spell',
name: 'Minor Wind Stone',
name: 'Wind (Push)',
level: 1,
magicname: 'Forceful Gust',
magicname: 'Push',
icon: 'blueGem.png',
target: 'target',
magiccost: 4,
effect: 'elemental-damage',
magnitude: 2,
magnitude: 1,
usedby: ['mage', 'healer'],
groups: ['default'],
elements: ['wind'],
Expand All @@ -21,9 +21,9 @@ export const MAGIC_DATA: ITemplateMagic[] = [
{
id: 'heal',
type: 'spell',
name: 'Minor Life Stone',
name: 'Heal',
level: 2,
magicname: 'Healing Bubbles',
magicname: 'Heal',
icon: 'turqoiseGem.png',
target: 'target',
magiccost: 12,
Expand Down
Loading

0 comments on commit 15df6db

Please sign in to comment.