1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-06-13 13:04:03 +00:00

Deliver in order and changed level definitions

This commit is contained in:
DJ1TJOO 2021-06-29 12:59:04 +02:00
parent 596fe59425
commit 2b3e1eef5c
7 changed files with 201 additions and 141 deletions

View File

@ -107,16 +107,19 @@ export class HubGoals extends BasicSerializableObject {
/** /**
* @type {{ * @type {{
* definitions: ShapeDefinition[], * definitions: Array<{
* requires: Array<{ * shape: ShapeDefinition,
* throughputOnly?: Boolean,
* amount: Number, * amount: Number,
* throughputOnly?: Boolean,
* }>, * }>,
* reward: enumHubGoalRewards, * reward: enumHubGoalRewards,
* inOrder?: Boolean,
* }} * }}
*/ */
this.currentGoal = null; this.currentGoal = null;
this.deliverOrder = [];
this.computeNextGoal(); this.computeNextGoal();
// Allow quickly switching goals in dev mode // Allow quickly switching goals in dev mode
@ -182,15 +185,15 @@ export class HubGoals extends BasicSerializableObject {
const currentGoalDeliverd = []; const currentGoalDeliverd = [];
for (let i = 0; i < this.currentGoal.definitions.length; i++) { for (let i = 0; i < this.currentGoal.definitions.length; i++) {
if (this.currentGoal.requires[i].throughputOnly) { if (this.currentGoal.definitions[i].throughputOnly) {
currentGoalDeliverd.push( currentGoalDeliverd.push(
this.root.productionAnalytics.getCurrentShapeRateRaw( this.root.productionAnalytics.getCurrentShapeRateRaw(
enumAnalyticsDataSource.delivered, enumAnalyticsDataSource.delivered,
this.currentGoal.definitions[i] this.currentGoal.definitions[i].shape
) / globalConfig.analyticsSliceDurationSeconds ) / globalConfig.analyticsSliceDurationSeconds
); );
} else { } else {
currentGoalDeliverd.push(this.getShapesStored(this.currentGoal.definitions[i])); currentGoalDeliverd.push(this.getShapesStored(this.currentGoal.definitions[i].shape));
} }
} }
return currentGoalDeliverd; return currentGoalDeliverd;
@ -203,7 +206,7 @@ export class HubGoals extends BasicSerializableObject {
const delivered = this.getCurrentGoalDelivered(); const delivered = this.getCurrentGoalDelivered();
for (let i = 0; i < delivered.length; i++) { for (let i = 0; i < delivered.length; i++) {
if (delivered[i] < this.currentGoal.requires[i].amount) return false; if (delivered[i] < this.currentGoal.definitions[i].amount) return false;
} }
return true; return true;
@ -239,9 +242,52 @@ export class HubGoals extends BasicSerializableObject {
*/ */
handleDefinitionDelivered(definition) { handleDefinitionDelivered(definition) {
const hash = definition.getHash(); const hash = definition.getHash();
const definitions = this.currentGoal.definitions;
// In order and shape is goal shape
if (this.currentGoal.inOrder && definitions.some(goal => goal.shape.getHash() === hash)) {
// Add to delivered order
this.deliverOrder.push(hash);
if (this.deliverOrder.length === definitions.length) {
// Check if order is correct
const startIndex = this.deliverOrder.findIndex(
hash => hash === definitions[0].shape.getHash()
);
if (startIndex > -1) {
for (let i = 0; i < definitions.length; i++) {
// Offset order to first shape
let currentOrder = startIndex + i;
if (currentOrder >= this.deliverOrder.length)
currentOrder = currentOrder - this.deliverOrder.length;
// Wrong order clear order
if (this.deliverOrder[currentOrder] !== definitions[i].shape.getHash()) {
this.deliverOrder = [];
break;
}
}
} else {
this.deliverOrder = [];
}
// Add to stored shapes
for (let i = 0; i < this.deliverOrder.length; i++) {
this.storedShapes[this.deliverOrder[i]] =
(this.storedShapes[this.deliverOrder[i]] || 0) + 1;
this.root.signals.shapeDelivered.dispatch(
ShapeDefinition.fromShortKey(this.deliverOrder[i])
);
}
this.deliverOrder = [];
}
} else {
this.storedShapes[hash] = (this.storedShapes[hash] || 0) + 1; this.storedShapes[hash] = (this.storedShapes[hash] || 0) + 1;
this.root.signals.shapeDelivered.dispatch(definition); this.root.signals.shapeDelivered.dispatch(definition);
}
// Check if we have enough for the next level // Check if we have enough for the next level
if (this.isGoalCompleted() || (G_IS_DEV && globalConfig.debug.rewardsInstant)) { if (this.isGoalCompleted() || (G_IS_DEV && globalConfig.debug.rewardsInstant)) {
@ -258,12 +304,18 @@ export class HubGoals extends BasicSerializableObject {
const storyIndex = this.level - 1; const storyIndex = this.level - 1;
const levels = this.root.gameMode.getLevelDefinitions(); const levels = this.root.gameMode.getLevelDefinitions();
if (storyIndex < levels.length) { if (storyIndex < levels.length) {
const { shapes, requires, reward } = levels[storyIndex]; const { shapes, reward, inOrder } = levels[storyIndex];
if (shapes) { if (shapes) {
this.currentGoal = { this.currentGoal = {
definitions: shapes.map(code => this.root.shapeDefinitionMgr.getShapeFromShortKey(code)), definitions: shapes.map(shape => {
requires: requires, return {
...shape,
shape: this.root.shapeDefinitionMgr.getShapeFromShortKey(shape.key),
key: null,
};
}),
reward, reward,
inOrder,
}; };
return; return;
} }
@ -272,8 +324,9 @@ export class HubGoals extends BasicSerializableObject {
//Floor Required amount to remove confusion //Floor Required amount to remove confusion
const required = Math.min(200, Math.floor(4 + (this.level - 27) * 0.25)); const required = Math.min(200, Math.floor(4 + (this.level - 27) * 0.25));
this.currentGoal = { this.currentGoal = {
definitions: [this.computeFreeplayShape(this.level)], definitions: [
requires: [{ throughputOnly: true, amount: required }], { shape: this.computeFreeplayShape(this.level), throughputOnly: true, amount: required },
],
reward: enumHubGoalRewards.no_reward_freeplay, reward: enumHubGoalRewards.no_reward_freeplay,
}; };
} }

View File

@ -104,10 +104,10 @@ export class HUDPinnedShapes extends BaseHUDPart {
*/ */
findGoalValueForShape(key) { findGoalValueForShape(key) {
const goalIndex = this.root.hubGoals.currentGoal.definitions.findIndex( const goalIndex = this.root.hubGoals.currentGoal.definitions.findIndex(
shape => shape.getHash() === key goal => goal.shape.getHash() === key
); );
if (goalIndex > -1) { if (goalIndex > -1) {
return this.root.hubGoals.currentGoal.requires[goalIndex].amount; return this.root.hubGoals.currentGoal.definitions[goalIndex].amount;
} }
if (key === this.root.gameMode.getBlueprintShapeKey()) { if (key === this.root.gameMode.getBlueprintShapeKey()) {
return null; return null;
@ -142,7 +142,7 @@ export class HUDPinnedShapes extends BaseHUDPart {
*/ */
isShapePinned(key) { isShapePinned(key) {
const goalIndex = this.root.hubGoals.currentGoal.definitions.findIndex( const goalIndex = this.root.hubGoals.currentGoal.definitions.findIndex(
shape => shape.getHash() === key goal => goal.shape.getHash() === key
); );
if (goalIndex > -1 || key === this.root.gameMode.getBlueprintShapeKey()) { if (goalIndex > -1 || key === this.root.gameMode.getBlueprintShapeKey()) {
// This is a "special" shape which is always pinned // This is a "special" shape which is always pinned
@ -174,12 +174,11 @@ export class HUDPinnedShapes extends BaseHUDPart {
// Pin story goal // Pin story goal
for (let i = 0; i < currentGoal.definitions.length; i++) { for (let i = 0; i < currentGoal.definitions.length; i++) {
console.log(currentGoal);
this.internalPinShape({ this.internalPinShape({
key: currentGoal.definitions[i].getHash(), key: currentGoal.definitions[i].shape.getHash(),
canUnpin: false, canUnpin: false,
className: "goal", className: "goal",
throughputOnly: currentGoal.requires[i].throughputOnly, throughputOnly: currentGoal.definitions[i].throughputOnly,
}); });
} }
@ -195,7 +194,7 @@ export class HUDPinnedShapes extends BaseHUDPart {
// Pin manually pinned shapes // Pin manually pinned shapes
for (let i = 0; i < this.pinnedShapes.length; ++i) { for (let i = 0; i < this.pinnedShapes.length; ++i) {
const key = this.pinnedShapes[i]; const key = this.pinnedShapes[i];
const goalIndex = currentGoal.definitions.findIndex(shape => shape.getHash() === key); const goalIndex = currentGoal.definitions.findIndex(goal => goal.shape.getHash() === key);
if (goalIndex < 0) { if (goalIndex < 0) {
this.internalPinShape({ key }); this.internalPinShape({ key });
} }
@ -315,7 +314,7 @@ export class HUDPinnedShapes extends BaseHUDPart {
pinNewShape(definition) { pinNewShape(definition) {
const key = definition.getHash(); const key = definition.getHash();
const goalIndex = this.root.hubGoals.currentGoal.definitions.findIndex( const goalIndex = this.root.hubGoals.currentGoal.definitions.findIndex(
shape => shape.getHash() === key goal => goal.shape.getHash() === key
); );
if (goalIndex > -1) { if (goalIndex > -1) {
// Can not pin current goal // Can not pin current goal

View File

@ -48,6 +48,7 @@ export class HUDSandboxController extends BaseHUDPart {
<div class="additionalOptions"> <div class="additionalOptions">
<button class="styledButton giveBlueprints">Fill blueprint shapes</button> <button class="styledButton giveBlueprints">Fill blueprint shapes</button>
<button class="styledButton maxOutAll">Max out all</button> <button class="styledButton maxOutAll">Max out all</button>
<button class="styledButton clearAll">Clear all</button>
</div> </div>
</div> </div>
` `
@ -57,6 +58,7 @@ export class HUDSandboxController extends BaseHUDPart {
bind(".giveBlueprints", this.giveBlueprints); bind(".giveBlueprints", this.giveBlueprints);
bind(".maxOutAll", this.maxOutAll); bind(".maxOutAll", this.maxOutAll);
bind(".clearAll", this.clearAll);
bind(".levelToggle .minus", () => this.modifyLevel(-1)); bind(".levelToggle .minus", () => this.modifyLevel(-1));
bind(".levelToggle .plus", () => this.modifyLevel(1)); bind(".levelToggle .plus", () => this.modifyLevel(1));
@ -81,6 +83,13 @@ export class HUDSandboxController extends BaseHUDPart {
this.root.hubGoals.storedShapes[shape] += 1e9; this.root.hubGoals.storedShapes[shape] += 1e9;
} }
clearAll() {
this.modifyUpgrade("belt", -1000);
this.modifyUpgrade("miner", -1000);
this.modifyUpgrade("processors", -1000);
this.modifyUpgrade("painting", -1000);
}
maxOutAll() { maxOutAll() {
this.modifyUpgrade("belt", 100); this.modifyUpgrade("belt", 100);
this.modifyUpgrade("miner", 100); this.modifyUpgrade("miner", 100);
@ -117,7 +126,7 @@ export class HUDSandboxController extends BaseHUDPart {
// Clear all shapes of this level // Clear all shapes of this level
for (let i = 0; i < hubGoals.currentGoal.definitions.length; i++) { for (let i = 0; i < hubGoals.currentGoal.definitions.length; i++) {
hubGoals.storedShapes[hubGoals.currentGoal.definitions[i].getHash()] = 0; hubGoals.storedShapes[hubGoals.currentGoal.definitions[i].shape.getHash()] = 0;
} }
if (this.root.hud.parts.pinnedShapes) { if (this.root.hud.parts.pinnedShapes) {

View File

@ -124,7 +124,7 @@ export class HUDShop extends BaseHUDPart {
container.appendChild(viewInfoButton); container.appendChild(viewInfoButton);
const goalIndex = this.root.hubGoals.currentGoal.definitions.findIndex( const goalIndex = this.root.hubGoals.currentGoal.definitions.findIndex(
goal => goal.getHash() === shape goal => goal.shape.getHash() === shape
); );
if (goalIndex > -1) { if (goalIndex > -1) {
pinButton.classList.add("isGoal"); pinButton.classList.add("isGoal");

View File

@ -56,12 +56,13 @@ import { MetaItemProducerBuilding } from "../buildings/item_producer";
/** /**
* @typedef {{ * @typedef {{
* shapes: String[], * shapes: String[] | Array<{
* requires: Array<{ * key: String,
* throughputOnly?: Boolean,
* amount: Number, * amount: Number,
* throughputOnly?: Boolean,
* }>, * }>,
* reward: enumHubGoalRewards, * reward: enumHubGoalRewards,
* inOrder?: Boolean,
* }} LevelDefinition */ * }} LevelDefinition */
export const rocketShape = "CbCuCbCu:Sr------:--CrSrCr:CwCwCwCw"; export const rocketShape = "CbCuCbCu:Sr------:--CrSrCr:CwCwCwCw";
@ -299,101 +300,88 @@ export function generateLevelDefinitions(limitedVersion = false) {
// 1 // 1
// Circle // Circle
{ {
shapes: ["CuCuCuCu"], // belts t1 shapes: [{ key: "CuCuCuCu", amount: 30 }], // belts t1
requires: [{ amount: 30 }],
reward: enumHubGoalRewards.reward_cutter_and_trash, reward: enumHubGoalRewards.reward_cutter_and_trash,
}, },
// 2 // 2
// Cutter // Cutter
{ {
shapes: ["----CuCu"], // shapes: [{ key: "----CuCu", amount: 40 }], //
requires: [{ amount: 40 }],
reward: enumHubGoalRewards.no_reward, reward: enumHubGoalRewards.no_reward,
}, },
// 3 // 3
// Rectangle // Rectangle
{ {
shapes: ["RuRuRuRu"], // miners t1 shapes: [{ key: "RuRuRuRu", amount: 70 }], // miners t1
requires: [{ amount: 70 }],
reward: enumHubGoalRewards.reward_balancer, reward: enumHubGoalRewards.reward_balancer,
}, },
// 4 // 4
{ {
shapes: ["RuRu----"], // processors t2 shapes: [{ key: "RuRu----", amount: 70 }], // processors t2
requires: [{ amount: 70 }],
reward: enumHubGoalRewards.reward_rotater, reward: enumHubGoalRewards.reward_rotater,
}, },
// 5 // 5
// Rotater // Rotater
{ {
shapes: ["Cu----Cu"], // belts t2 shapes: [{ key: "Cu----Cu", amount: 170 }], // belts t2
requires: [{ amount: 170 }],
reward: enumHubGoalRewards.reward_tunnel, reward: enumHubGoalRewards.reward_tunnel,
}, },
// 6 // 6
{ {
shapes: ["Cu------"], // miners t2 shapes: [{ key: "Cu------", amount: 270 }], // miners t2
requires: [{ amount: 270 }],
reward: enumHubGoalRewards.reward_painter, reward: enumHubGoalRewards.reward_painter,
}, },
// 7 // 7
// Painter // Painter
{ {
shapes: ["CrCrCrCr"], // unused shapes: [{ key: "CrCrCrCr", amount: 300 }], // unused
requires: [{ amount: 300 }],
reward: enumHubGoalRewards.reward_rotater_ccw, reward: enumHubGoalRewards.reward_rotater_ccw,
}, },
// 8 // 8
{ {
shapes: ["RbRb----"], // painter t2 shapes: [{ key: "RbRb----", amount: 480 }], // painter t2
requires: [{ amount: 480 }],
reward: enumHubGoalRewards.reward_mixer, reward: enumHubGoalRewards.reward_mixer,
}, },
// 9 // 9
// Mixing (purple) // Mixing (purple)
{ {
shapes: ["CpCpCpCp"], // belts t3 shapes: [{ key: "CpCpCpCp", amount: 600 }], // belts t3
requires: [{ amount: 600 }],
reward: enumHubGoalRewards.reward_merger, reward: enumHubGoalRewards.reward_merger,
}, },
// 10 // 10
// STACKER: Star shapes + cyan // STACKER: Star shapes + cyan
{ {
shapes: ["ScScScSc"], // miners t3 shapes: [{ key: "ScScScSc", amount: 800 }], // miners t3
requires: [{ amount: 800 }],
reward: enumHubGoalRewards.reward_stacker, reward: enumHubGoalRewards.reward_stacker,
}, },
// 11 // 11
// Chainable miner // Chainable miner
{ {
shapes: ["CgScScCg"], // processors t3 shapes: [{ key: "CgScScCg", amount: 1000 }], // processors t3
requires: [{ amount: 1000 }],
reward: enumHubGoalRewards.reward_miner_chainable, reward: enumHubGoalRewards.reward_miner_chainable,
}, },
// 12 // 12
// Blueprints // Blueprints
{ {
shapes: ["CbCbCbRb:CwCwCwCw"], shapes: [{ key: "CbCbCbRb:CwCwCwCw", amount: 1000 }],
requires: [{ amount: 1000 }],
reward: enumHubGoalRewards.reward_blueprints, reward: enumHubGoalRewards.reward_blueprints,
}, },
// 13 // 13
// Tunnel Tier 2 // Tunnel Tier 2
{ {
shapes: [chinaShapes ? "CuCuCuCu:CwCwCwCw:Sb--Sr--" : "RpRpRpRp:CwCwCwCw"], // painting t3 shapes: [{ key: chinaShapes ? "CuCuCuCu:CwCwCwCw:Sb--Sr--" : "RpRpRpRp:CwCwCwCw", amount: 3800 }], // painting t3
requires: [{ amount: 3800 }],
reward: enumHubGoalRewards.reward_underground_belt_tier_2, reward: enumHubGoalRewards.reward_underground_belt_tier_2,
}, },
@ -401,8 +389,12 @@ export function generateLevelDefinitions(limitedVersion = false) {
...(limitedVersion ...(limitedVersion
? [ ? [
{ {
shapes: [chinaShapes ? "CuCuCuCu:CwCwCwCw:Sb--Sr--" : "RpRpRpRp:CwCwCwCw"], shapes: [
requires: [{ amount: 0 }], {
key: chinaShapes ? "CuCuCuCu:CwCwCwCw:Sb--Sr--" : "RpRpRpRp:CwCwCwCw",
amount: 0,
},
],
reward: enumHubGoalRewards.reward_demo_end, reward: enumHubGoalRewards.reward_demo_end,
}, },
] ]
@ -410,24 +402,21 @@ export function generateLevelDefinitions(limitedVersion = false) {
// 14 // 14
// Belt reader // Belt reader
{ {
shapes: ["--Cg----:--Cr----"], // unused shapes: [{ key: "--Cg----:--Cr----", amount: 8, throughputOnly: true }], // unused
requires: [{ amount: 8, throughputOnly: true }], // Per second!
reward: enumHubGoalRewards.reward_belt_reader, reward: enumHubGoalRewards.reward_belt_reader,
}, },
// 15 // 15
// Storage // Storage
{ {
shapes: ["SrSrSrSr:CyCyCyCy"], // unused shapes: [{ key: "SrSrSrSr:CyCyCyCy", amount: 10000 }], // unused
requires: [{ amount: 10000 }],
reward: enumHubGoalRewards.reward_storage, reward: enumHubGoalRewards.reward_storage,
}, },
// 16 // 16
// Quad Cutter // Quad Cutter
{ {
shapes: ["SrSrSrSr:CyCyCyCy:SwSwSwSw"], // belts t4 (two variants) shapes: [{ key: "SrSrSrSr:CyCyCyCy:SwSwSwSw", amount: 6000 }], // belts t4 (two variants)
requires: [{ amount: 6000 }],
reward: enumHubGoalRewards.reward_cutter_quad, reward: enumHubGoalRewards.reward_cutter_quad,
}, },
@ -435,41 +424,41 @@ export function generateLevelDefinitions(limitedVersion = false) {
// Double painter // Double painter
{ {
shapes: [ shapes: [
chinaShapes ? "CyCyCyCy:CyCyCyCy:RyRyRyRy:RuRuRuRu" : "CbRbRbCb:CwCwCwCw:WbWbWbWb", {
key: chinaShapes
? "CyCyCyCy:CyCyCyCy:RyRyRyRy:RuRuRuRu"
: "CbRbRbCb:CwCwCwCw:WbWbWbWb",
amount: 20000,
},
], // miner t4 (two variants) ], // miner t4 (two variants)
requires: [{ amount: 20000 }],
reward: enumHubGoalRewards.reward_painter_double, reward: enumHubGoalRewards.reward_painter_double,
}, },
// 18 // 18
// Rotater (180deg) // Rotater (180deg)
{ {
shapes: ["Sg----Sg:CgCgCgCg:--CyCy--"], // unused shapes: [{ key: "Sg----Sg:CgCgCgCg:--CyCy--", amount: 20000 }], // unused
requires: [{ amount: 20000 }],
reward: enumHubGoalRewards.reward_rotater_180, reward: enumHubGoalRewards.reward_rotater_180,
}, },
// 19 // 19
// Compact splitter // Compact splitter
{ {
shapes: ["CpRpCp--:SwSwSwSw"], shapes: [{ key: "CpRpCp--:SwSwSwSw", amount: 25000 }],
requires: [{ amount: 25000 }],
reward: enumHubGoalRewards.reward_splitter, reward: enumHubGoalRewards.reward_splitter,
}, },
// 20 // 20
// WIRES // WIRES
{ {
shapes: [finalGameShape], shapes: [{ key: finalGameShape, amount: 25000 }],
requires: [{ amount: 25000 }],
reward: enumHubGoalRewards.reward_wires_painter_and_levers, reward: enumHubGoalRewards.reward_wires_painter_and_levers,
}, },
// 21 // 21
// Filter // Filter
{ {
shapes: ["CrCwCrCw:CwCrCwCr:CrCwCrCw:CwCrCwCr"], shapes: [{ key: "CrCwCrCw:CwCrCwCr:CrCwCrCw:CwCrCwCr", amount: 25000 }],
requires: [{ amount: 25000 }],
reward: enumHubGoalRewards.reward_filter, reward: enumHubGoalRewards.reward_filter,
}, },
@ -477,9 +466,13 @@ export function generateLevelDefinitions(limitedVersion = false) {
// Constant signal // Constant signal
{ {
shapes: [ shapes: [
chinaShapes ? "RrSySrSy:RyCrCwCr:CyCyRyCy" : "Cg----Cr:Cw----Cw:Sy------:Cy----Cy", {
key: chinaShapes
? "RrSySrSy:RyCrCwCr:CyCyRyCy"
: "Cg----Cr:Cw----Cw:Sy------:Cy----Cy",
amount: 25000,
},
], ],
requires: [{ amount: 25000 }],
reward: enumHubGoalRewards.reward_constant_signal, reward: enumHubGoalRewards.reward_constant_signal,
}, },
@ -487,62 +480,63 @@ export function generateLevelDefinitions(limitedVersion = false) {
// Display // Display
{ {
shapes: [ shapes: [
chinaShapes ? "CrCrCrCr:CwCwCwCw:WwWwWwWw:CrCrCrCr" : "CcSyCcSy:SyCcSyCc:CcSyCcSy", {
key: chinaShapes
? "CrCrCrCr:CwCwCwCw:WwWwWwWw:CrCrCrCr"
: "CcSyCcSy:SyCcSyCc:CcSyCcSy",
amount: 25000,
},
], ],
requires: [{ amount: 25000 }],
reward: enumHubGoalRewards.reward_display, reward: enumHubGoalRewards.reward_display,
}, },
// 24 Logic gates // 24 Logic gates
{ {
shapes: [ shapes: [
chinaShapes {
key: chinaShapes
? "Su----Su:RwRwRwRw:Cu----Cu:CwCwCwCw" ? "Su----Su:RwRwRwRw:Cu----Cu:CwCwCwCw"
: "CcRcCcRc:RwCwRwCw:Sr--Sw--:CyCyCyCy", : "CcRcCcRc:RwCwRwCw:Sr--Sw--:CyCyCyCy",
amount: 25000,
},
], ],
requires: [{ amount: 25000 }],
reward: enumHubGoalRewards.reward_logic_gates, reward: enumHubGoalRewards.reward_logic_gates,
}, },
// 25 Virtual Processing // 25 Virtual Processing
{ {
shapes: ["Rg--Rg--:CwRwCwRw:--Rg--Rg"], shapes: [{ key: "Rg--Rg--:CwRwCwRw:--Rg--Rg", amount: 25000 }],
requires: [{ amount: 25000 }],
reward: enumHubGoalRewards.reward_virtual_processing, reward: enumHubGoalRewards.reward_virtual_processing,
}, },
// 26 Freeplay // 26 Freeplay
{ {
shapes: ["CbCuCbCu:Sr------:--CrSrCr:CwCwCwCw"], shapes: [{ key: "CbCuCbCu:Sr------:--CrSrCr:CwCwCwCw", amount: 50000 }],
requires: [{ amount: 50000 }],
reward: enumHubGoalRewards.reward_freeplay, reward: enumHubGoalRewards.reward_freeplay,
}, },
// 27 Random // 27 Random
{ {
shapes: null, shapes: null,
requires: null,
reward: null, reward: null,
}, },
// 28 More shapes // 28 More shapes
{ {
shapes: ["CbCuCbCu:Sr------:--CrSrCr:CwCwCwCw", "Rg--Rg--:CwRwCwRw:--Rg--Rg"], shapes: [
requires: [{ amount: 50000 }, { amount: 30000, throughputOnly: true }], { key: "CbCuCbCu:Sr------:--CrSrCr:CwCwCwCw", amount: 50000 },
{ key: "Rg--Rg--:CwRwCwRw:--Rg--Rg", amount: 30000, throughputOnly: true },
],
reward: enumHubGoalRewards.reward_freeplay, reward: enumHubGoalRewards.reward_freeplay,
inOrder: true,
}, },
// 29 More shapes // 29 More shapes
{ {
shapes: [ shapes: [
"CbCuCbCu:Sr------:--CrSrCr:CwCwCwCw", { key: "CbCuCbCu:Sr------:--CrSrCr:CwCwCwCw", amount: 50000 },
"Rg--Rg--:CwRwCwRw:--Rg--Rg", { key: "Rg--Rg--:CwRwCwRw:--Rg--Rg", amount: 30000, throughputOnly: true },
"Su----Su:RwRwRwRw:Cu----Cu:CwCwCwCw", { key: "Su----Su:RwRwRwRw:Cu----Cu:CwCwCwCw", amount: 70000, throughputOnly: true },
],
requires: [
{ amount: 50000 },
{ amount: 30000, throughputOnly: true },
{ amount: 70000, throughputOnly: true },
], ],
reward: enumHubGoalRewards.reward_freeplay, reward: enumHubGoalRewards.reward_freeplay,
}, },
@ -550,16 +544,24 @@ export function generateLevelDefinitions(limitedVersion = false) {
// 30 More shapes // 30 More shapes
{ {
shapes: [ shapes: [
"CbCuCbCu:Sr------:--CrSrCr:CwCwCwCw", {
"Rg--Rg--:CwRwCwRw:--Rg--Rg", key: "CbCuCbCu:Sr------:--CrSrCr:CwCwCwCw",
"Su----Su:RwRwRwRw:Cu----Cu:CwCwCwCw", amount: 50000,
"CrCrCrCr:CwCwCwCw:WwWwWwWw:CrCrCrCr", },
], {
requires: [ key: "Rg--Rg--:CwRwCwRw:--Rg--Rg",
{ amount: 50000 }, amount: 30000,
{ amount: 30000, throughputOnly: true }, throughputOnly: true,
{ amount: 70000, throughputOnly: true }, },
{ amount: 90000 }, {
key: "Su----Su:RwRwRwRw:Cu----Cu:CwCwCwCw",
amount: 70000,
throughputOnly: true,
},
{
key: "CrCrCrCr:CwCwCwCw:WwWwWwWw:CrCrCrCr",
amount: 90000,
},
], ],
reward: enumHubGoalRewards.reward_freeplay, reward: enumHubGoalRewards.reward_freeplay,
}, },
@ -570,11 +572,11 @@ export function generateLevelDefinitions(limitedVersion = false) {
levelDefinitions.forEach(({ shapes }) => { levelDefinitions.forEach(({ shapes }) => {
if (!shapes) return; if (!shapes) return;
shapes.forEach(shape => { shapes.forEach(goal => {
try { try {
ShapeDefinition.fromShortKey(shape); ShapeDefinition.fromShortKey(goal.key);
} catch (ex) { } catch (ex) {
throw new Error("Invalid tutorial goal: '" + ex + "' for shape" + shape); throw new Error("Invalid tutorial goal: '" + ex + "' for shape" + goal.key);
} }
}); });
}); });

View File

@ -78,7 +78,7 @@ export class ConstantSignalSystem extends GameSystemWithFilter {
for (let i = 0; i < this.root.hubGoals.currentGoal.definitions.length; i++) { for (let i = 0; i < this.root.hubGoals.currentGoal.definitions.length; i++) {
items.push( items.push(
this.root.shapeDefinitionMgr.getShapeItemFromDefinition( this.root.shapeDefinitionMgr.getShapeItemFromDefinition(
this.root.hubGoals.currentGoal.definitions[i] this.root.hubGoals.currentGoal.definitions[i].shape
) )
); );
} }

View File

@ -42,7 +42,7 @@ export class HubSystem extends GameSystemWithFilter {
} }
pinsComp.slots[i].value = this.root.shapeDefinitionMgr.getShapeItemFromDefinition( pinsComp.slots[i].value = this.root.shapeDefinitionMgr.getShapeItemFromDefinition(
this.root.hubGoals.currentGoal.definitions[i] this.root.hubGoals.currentGoal.definitions[i].shape
); );
} }
} }
@ -84,53 +84,50 @@ export class HubSystem extends GameSystemWithFilter {
} }
const goals = this.root.hubGoals.currentGoal; const goals = this.root.hubGoals.currentGoal;
const goalsLength = goals.definitions.length;
const delivered = this.root.hubGoals.getCurrentGoalDelivered(); const delivered = this.root.hubGoals.getCurrentGoalDelivered();
for (let i = 0; i < goals.definitions.length; i++) {
const x = let x = 45;
45 + let y = 58 + (goalsLength > 1 ? -3 : 0);
(goals.definitions.length > 3
? 22 * i - 14 if (goalsLength > 3) x += -36;
: goals.definitions.length > 2 else if (goalsLength > 2) x += -36;
? 28 * i - 8 else if (goalsLength > 1) x += -44;
: goals.definitions.length > 1
? 43 * i let size = 36;
: 0); if (goalsLength > 3) size = 20;
const y = 58 + (goals.definitions.length > 1 ? -3 : 0); else if (goalsLength > 2) size = 26;
goals.definitions[i].drawCentered( else if (goalsLength > 1) size = 32;
x,
y, for (let i = 0; i < goalsLength; i++) {
parameters, if (goalsLength > 3) x += 22;
goals.definitions.length > 3 else if (goalsLength > 2) x += 28;
? 20 else if (goalsLength > 1) x += 43;
: goals.definitions.length > 2
? 26 goals.definitions[i].shape.drawCentered(x, y, parameters, size);
: goals.definitions.length > 1
? 32
: 36
);
const textOffsetX = 0; const textOffsetX = 0;
const textOffsetY = 24; const textOffsetY = 24;
if (goals.requires[i].throughputOnly) { if (goals.definitions[i].throughputOnly) {
// Throughput // Throughput
const deliveredText = T.ingame.statistics.shapesDisplayUnits.second.replace( const deliveredText = T.ingame.statistics.shapesDisplayUnits.second.replace(
"<shapes>", "<shapes>",
formatBigNumber(goals.requires[i].amount) formatBigNumber(goals.definitions[i].amount)
); );
if (goals.definitions.length > 3) { if (goalsLength > 3) {
context.font = "bold 6px GameFont"; context.font = "bold 6px GameFont";
context.fillStyle = "#64666e"; context.fillStyle = "#64666e";
context.textAlign = "left"; context.textAlign = "left";
const offset = context.measureText(deliveredText).width; const offset = context.measureText(deliveredText).width;
context.fillText(deliveredText, textOffsetX + x - offset / 2, textOffsetY + y - 6); context.fillText(deliveredText, textOffsetX + x - offset / 2, textOffsetY + y - 6);
} else if (goals.definitions.length > 2) { } else if (goalsLength > 2) {
context.font = "bold 6px GameFont"; context.font = "bold 6px GameFont";
context.fillStyle = "#64666e"; context.fillStyle = "#64666e";
context.textAlign = "left"; context.textAlign = "left";
const offset = context.measureText(deliveredText).width; const offset = context.measureText(deliveredText).width;
context.fillText(deliveredText, textOffsetX + x - offset / 2, textOffsetY + y - 4); context.fillText(deliveredText, textOffsetX + x - offset / 2, textOffsetY + y - 4);
} else if (goals.definitions.length > 1) { } else if (goalsLength > 1) {
context.font = "bold 8px GameFont"; context.font = "bold 8px GameFont";
context.fillStyle = "#64666e"; context.fillStyle = "#64666e";
context.textAlign = "left"; context.textAlign = "left";
@ -144,9 +141,9 @@ export class HubSystem extends GameSystemWithFilter {
context.fillText(deliveredText, textOffsetX + 86 - offset / 2, textOffsetY + 40); context.fillText(deliveredText, textOffsetX + 86 - offset / 2, textOffsetY + 40);
} }
} else { } else {
const textRequired = "/" + formatBigNumber(goals.requires[i].amount); const textRequired = "/" + formatBigNumber(goals.definitions[i].amount);
const textDelivered = formatBigNumber(delivered[i]); const textDelivered = formatBigNumber(delivered[i]);
if (goals.definitions.length > 3) { if (goalsLength > 3) {
context.font = "6px GameFont"; context.font = "6px GameFont";
const offsetRequired = context.measureText(textRequired).width; const offsetRequired = context.measureText(textRequired).width;
@ -167,7 +164,7 @@ export class HubSystem extends GameSystemWithFilter {
textOffsetX + x + offsetDelivered - totalOffset / 2, textOffsetX + x + offsetDelivered - totalOffset / 2,
textOffsetY + y - 6 textOffsetY + y - 6
); );
} else if (goals.definitions.length > 2) { } else if (goalsLength > 2) {
context.font = "6px GameFont"; context.font = "6px GameFont";
const offsetRequired = context.measureText(textRequired).width; const offsetRequired = context.measureText(textRequired).width;
@ -188,7 +185,7 @@ export class HubSystem extends GameSystemWithFilter {
textOffsetX + x + offsetDelivered - totalOffset / 2, textOffsetX + x + offsetDelivered - totalOffset / 2,
textOffsetY + y - 4 textOffsetY + y - 4
); );
} else if (goals.definitions.length > 1) { } else if (goalsLength > 1) {
context.font = "8px GameFont"; context.font = "8px GameFont";
const offsetRequired = context.measureText(textRequired).width; const offsetRequired = context.measureText(textRequired).width;