mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Co-authored-by: Janne Savolainen <janne.savolainen@live.fi> Signed-off-by: Iku-turso <mikko.aspiala@gmail.com>
35 lines
968 B
TypeScript
35 lines
968 B
TypeScript
import { getInjectable } from "@ogre-tools/injectable";
|
|
import monsterInjectable from "./monster";
|
|
import messageToPlayerInjectable from "./message-to-player";
|
|
|
|
const handleLandedHitOnMonsterInjectable = getInjectable({
|
|
id: "handle-landed-hit-on-monster",
|
|
|
|
instantiate: (di) => {
|
|
const monster = di.inject(monsterInjectable);
|
|
const messageToPlayer = di.inject(messageToPlayerInjectable);
|
|
|
|
return () => {
|
|
monster.hitPoints--;
|
|
|
|
if (monster.hitPoints) {
|
|
messageToPlayer(
|
|
`You successfully land a hit on the monster, and it now only has ${monster.hitPoints} hit-points remaining.`,
|
|
);
|
|
|
|
return { monsterIsDead: false };
|
|
}
|
|
|
|
messageToPlayer(
|
|
"You successfully land a final hit on the monster, and it is now properly beat.",
|
|
);
|
|
|
|
messageToPlayer("You win. Congratulations!");
|
|
|
|
return { monsterIsDead: true };
|
|
};
|
|
},
|
|
});
|
|
|
|
export default handleLandedHitOnMonsterInjectable;
|