Skip to content

Commit

Permalink
feat: add world class
Browse files Browse the repository at this point in the history
  • Loading branch information
TheoPierne committed Oct 17, 2022
1 parent 180a8bf commit 251e02f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/modules/elementWorld.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class ElementWorld {

static FLOOR : string = '#';
static BONUS : string = '[?]';
static FLOAT_PLAT : string = '_';

};

export default ElementWorld;
25 changes: 25 additions & 0 deletions src/modules/world.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const IRender = require('./interfaces/irender');

class World implements IRender {

private _world : string[][];

constructor(){
this._world = Array(16).fill('').map(() => Array(32).fill('1'));
}

getPos(x: number, y: number): string|undefined {
return this._world[x][y];
}

setPos(x: number, y: number, value: string): void {
this._world[x][y] = value;
}

render(): string {
return this._world.join('\n');
}

};

export default World;
5 changes: 3 additions & 2 deletions tests/main.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { describe, expect, test } from '@jest/globals';
/*import { describe, expect, test } from '@jest/globals';
import main from "../src/main";
describe('main function', () => {
test('main function returns the string "Hello, World!"', () => {
expect(main()).toMatch("Hello, World!");
})
});
});
*/

0 comments on commit 251e02f

Please sign in to comment.