Rework AI and add more stats
This commit is contained in:
parent
29832dfce3
commit
c8de53bfc7
14 changed files with 197 additions and 169 deletions
|
|
@ -4,14 +4,31 @@ import { type IUser, type TRole } from "./store/types.js";
|
|||
import type { ILevel } from "./types.js";
|
||||
|
||||
const getUserById = (userId: string): IUser => {
|
||||
return (
|
||||
state.users.find((user) => user.id === userId) ?? {
|
||||
const user = state.users.find((user) => user.id === userId);
|
||||
if (!user) {
|
||||
return {
|
||||
id: ":",
|
||||
role: "NONE",
|
||||
experience: 0,
|
||||
money: 0,
|
||||
aiCost: 0,
|
||||
lastMessageTimestamp: 0,
|
||||
}
|
||||
);
|
||||
lastExperienceGainTimestamp: 0,
|
||||
lastMoneyGainTimestamp: 0,
|
||||
};
|
||||
}
|
||||
|
||||
if (!user.experience) {
|
||||
user.experience = 0;
|
||||
}
|
||||
if (!user.money) {
|
||||
user.money = 0;
|
||||
}
|
||||
if (!user.aiCost) {
|
||||
user.aiCost = 0;
|
||||
}
|
||||
|
||||
return user;
|
||||
};
|
||||
|
||||
const checkRoles = (roles: TRole[], userId: string) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue