Skip to content

Commit

Permalink
Add new properties to IPlayerData
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-crane committed Feb 21, 2018
1 parent 56ea6dd commit f634dad
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 6 deletions.
8 changes: 8 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# Changelog
This changelog uses [Semantic Versioning 2.0.0](https://semver.org/).

## `6.14.1`
### Changes:
+ Added new properties to `IPlayerData`
+ `nameChosen: boolean` - Whether or not the player has chosen a unique name.
+ `guildName: string` - The name of the player's guild, or null if they are not in one.
+ `guildRank: GuildRank` - The guild rank of the player. See `GuildRank` for more info.
+ Added the `GuildRank` enum to map guild rank number codes to their in game ranks.

## `6.14.0`
### Changes:
+ Made `Client.guid` public.
Expand Down
19 changes: 19 additions & 0 deletions docs/models/guildrank.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# GuildRank
This is an enum which stores the number codes of all guild ranks.

Example usage:
```typescript
const playerData: IPlayerData = getMyPlayerDataSomehow();
Log('Guild Shower', 'Your guild rank is: ' + GuildRank[playerData.guildRank]);
```
The enum values are:
```typescript
enum enum GuildRank {
NoRank = -1,
Initiate = 0,
Member = 10,
Officer = 20,
Leader = 30,
Founder = 40
}
```
9 changes: 9 additions & 0 deletions docs/models/playerdata.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ The account id of the player.
#### `accountFame: number`
The account fame of the player.

#### `nameChosen: boolean`
Whether or not the player has chosen a unique name.

#### `guildName: string`
The name of the guild which the player is in, or null if they are not in a guild.

#### `guildRank: GuildRank`
The number code of the player's guild rank. See the `GuildRank` enum for more info.

#### `gold: number`
The amount of gold the player has.

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nrelay",
"version": "6.14.0",
"version": "6.14.1",
"description": "A console based modular client for Realm of the Mad God built with Node.js and TypeScript.",
"main": "index.js",
"bin": {
Expand Down
8 changes: 8 additions & 0 deletions src/models/guildrank.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export enum GuildRank {
NoRank = -1,
Initiate = 0,
Member = 10,
Officer = 20,
Leader = 30,
Founder = 40
}
17 changes: 12 additions & 5 deletions src/models/playerdata.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { WorldPosData } from './../networking/data/world-pos-data';
import { Classes } from './classes';
import { GuildRank } from './guildrank';

export interface IPlayerData {
objectId: number;
Expand All @@ -11,6 +12,9 @@ export interface IPlayerData {
stars: number;
accountId: string;
accountFame: number;
nameChosen: boolean;
guildName: string;
guildRank: GuildRank;
gold: number;
class: Classes;
maxHP: number;
Expand All @@ -28,8 +32,8 @@ export interface IPlayerData {
hasBackpack: boolean;
inventory: number[];
/**
* @deprecated Use `Client.server` instead.
* This is not gauranteed to be correct.
* @deprecated To get the server of a connect client, use `Client.server` instead.
* for any other use (such as the Player Tracker) using this is fine.
*/
server: string;
}
Expand All @@ -38,15 +42,18 @@ export function getDefaultPlayerData(): IPlayerData {
return {
objectId: 0,
worldPos: null,
name: '',
name: null,
level: 0,
exp: 0,
currentFame: 0,
stars: 0,
accountId: '',
accountId: null,
accountFame: 0,
gold: 0,
class: Classes.Wizard,
nameChosen: false,
guildName: null,
guildRank: GuildRank.NoRank,
maxHP: 0,
maxMP: 0,
hp: 0,
Expand All @@ -61,6 +68,6 @@ export function getDefaultPlayerData(): IPlayerData {
mpPots: 0,
hasBackpack: false,
inventory: new Array<number>(20).fill(-1),
server: ''
server: null
};
}
9 changes: 9 additions & 0 deletions src/networking/data/object-status-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@ export class ObjectStatusData {
case StatData.HASBACKPACK_STAT:
playerData.hasBackpack = data[i].statValue === 1;
continue;
case StatData.NAME_CHOSEN_STAT:
playerData.nameChosen = data[i].statValue !== 0;
continue;
case StatData.GUILD_NAME_STAT:
playerData.guildName = data[i].stringStatValue;
continue;
case StatData.GUILD_RANK_STAT:
playerData.guildRank = data[i].statValue;
continue;
default:
if (data[i].statType >= StatData.INVENTORY_0_STAT && data[i].statType <= StatData.INVENTORY_11_STAT) {
playerData.inventory[data[i].statType - 8] = data[i].statValue;
Expand Down

0 comments on commit f634dad

Please sign in to comment.