Skip to content

Commit

Permalink
Added gcl/rclPerTick difference
Browse files Browse the repository at this point in the history
  • Loading branch information
pieterbrandsen authored Feb 16, 2024
1 parent 94151f9 commit 402b7cb
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/data/converter/manage/ownedRoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,12 @@ export default async function handleObjects(data, opts) {
// #region Controller

if (controller) {
actions.push(ActionProcessor.CreateAction('controller.rclPerTick', controller._upgraded || 0,
actions.push(ActionProcessor.CreateAction('controller.gclPerTick', controller._upgraded || 0,
ActionProcessor.ActionType.Divide100))
if (controller.level < 8) {
actions.push(ActionProcessor.CreateAction('controller.rclPerTick', controller._upgraded || 0,
ActionProcessor.ActionType.Divide100))
}
}

// #endregion
Expand Down
1 change: 1 addition & 0 deletions src/data/converter/prepare/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export default async function prepareObject(object, originalObject) {

switch (object.type) {
case 'controller':
object.level = originalObject.level;
if (object._upgraded || object._upgraded === null) {
originalObject._upgraded = object._upgraded;
if (object._upgraded === null) object._upgraded = 0;
Expand Down
31 changes: 28 additions & 3 deletions tests/dataTypes/owned.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ describe("Owned data type process check", () => {
})
})
describe("Every tick", () => {
describe('should handle controller rclPerTick correctly', () => {
describe('should handle controller gcl/rclPerTick correctly', () => {
it('should handle static non changing values', async () => {
for (let i = 1; i <= 10; i += 1) {
const settings = [{
Expand All @@ -706,7 +706,7 @@ describe("Owned data type process check", () => {

const data = await testHelper1.process(settings)
const base = data.stats.users[data.opts.username].stats.combined.shards[data.opts.shard]
expect(base.controller.rclPerTick).toBe(Math.round(i * 0.99 * 100) / 100)
expect(base.controller.gclPerTick).toBe(Math.round(i * 0.99 * 100) / 100)
}
})
it('should handle fluctuating values', async () => {
Expand All @@ -730,7 +730,32 @@ describe("Owned data type process check", () => {

const data = await testHelper1.process(settings)
const base = data.stats.users[data.opts.username].stats.combined.shards[data.opts.shard]
expect(base.controller.rclPerTick).toBe(i * 0.5625)
expect(base.controller.gclPerTick).toBe(i * 0.5625)
}
})
it('should handle controller level rclPerTick correctly', async () => {
for (let i = 1; i <= 8; i += 1) {
const settings = [{
type: TestHelper.dataTypes.controller, data: {
0: {
level: i,
_upgraded: 1
},
25: {
_upgraded: 0.75
},
50: {
_upgraded: 0.5
},
75: {
_upgraded: null
}
}
}]

const data = await testHelper1.process(settings)
const base = data.stats.users[data.opts.username].stats.combined.shards[data.opts.shard]
expect(base.controller.rclPerTick).toBe(i < 8 ? 0.5625 : 0)
}
})
})
Expand Down

0 comments on commit 402b7cb

Please sign in to comment.