-
Notifications
You must be signed in to change notification settings - Fork 30.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add character class with speed and attack properties and methods to increase them. * **Character Class** - Create `Character` class with `speed` and `attack` properties. - Add methods `increaseSpeed` and `increaseAttack` to increase speed and attack respectively. * **Character Tests** - Add tests for `increaseSpeed` and `increaseAttack` methods in `character.test.ts`. * **Character Styles** - Add CSS styles for character, speed indicator, and attack indicator in `character.css`. * **Character HTML** - Add HTML structure to display character with speed and attack indicators in `character.html`. --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/microsoft/vscode/tree/169?shareId=XXXX-XXXX-XXXX-XXXX).
- Loading branch information
1 parent
e28a92f
commit e9f38e5
Showing
4 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
.character { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
} | ||
|
||
.speed-indicator, | ||
.attack-indicator { | ||
margin: 5px; | ||
padding: 10px; | ||
border: 1px solid #000; | ||
border-radius: 5px; | ||
background-color: #f0f0f0; | ||
} | ||
|
||
.speed-indicator { | ||
color: #007bff; | ||
} | ||
|
||
.attack-indicator { | ||
color: #dc3545; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Character</title> | ||
<link rel="stylesheet" href="character.css"> | ||
</head> | ||
<body> | ||
<div class="character"> | ||
<div class="speed-indicator">Speed: <span id="speed">10</span></div> | ||
<div class="attack-indicator">Attack: <span id="attack">5</span></div> | ||
</div> | ||
<script src="character.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Character } from './character'; | ||
|
||
describe('Character', () => { | ||
let character: Character; | ||
|
||
beforeEach(() => { | ||
character = new Character(10, 5); | ||
}); | ||
|
||
it('should increase speed', () => { | ||
character.increaseSpeed(5); | ||
assert.equal(character.speed, 15); | ||
}); | ||
|
||
it('should increase attack', () => { | ||
character.increaseAttack(3); | ||
assert.equal(character.attack, 8); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
export class Character { | ||
speed: number; | ||
attack: number; | ||
|
||
constructor(speed: number, attack: number) { | ||
this.speed = speed; | ||
this.attack = attack; | ||
} | ||
|
||
increaseSpeed(amount: number): void { | ||
this.speed += amount; | ||
} | ||
|
||
increaseAttack(amount: number): void { | ||
this.attack += amount; | ||
} | ||
} |