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

Minor puzzle adjustments

This commit is contained in:
tobspr 2021-05-03 22:06:13 +02:00
parent e5e12c3ff8
commit 62fc46f29f
11 changed files with 75 additions and 33 deletions

View File

@ -13,7 +13,7 @@
& { & {
/* @load-async */ /* @load-async */
background: rgba(#333538, 0.98) uiResource("dialog_bg_pattern.png") top left / #{D(10px)} repeat; background: rgba(#333538, 0.95) uiResource("dialog_bg_pattern.png") top left / #{D(10px)} repeat;
} }
@include InlineAnimation(0.1s ease-in-out) { @include InlineAnimation(0.1s ease-in-out) {
@ -130,6 +130,12 @@
align-items: center; align-items: center;
@include S(margin-bottom, 10px); @include S(margin-bottom, 10px);
> .desc {
@include SuperSmallText;
opacity: 0.4;
@include S(margin-bottom, 4px);
}
> .shapes { > .shapes {
@include S(margin-top, 10px); @include S(margin-top, 10px);
display: flex; display: flex;

View File

@ -62,8 +62,8 @@
> .puzzles { > .puzzles {
display: grid; display: grid;
grid-template-columns: repeat(auto-fit, minmax(D(150px), 1fr)); grid-template-columns: repeat(auto-fit, minmax(D(130px), 1fr));
@include S(grid-auto-rows, 120px); @include S(grid-auto-rows, 90px);
@include S(grid-gap, 3px); @include S(grid-gap, 3px);
@include S(margin-top, 10px); @include S(margin-top, 10px);
@include S(padding-right, 4px); @include S(padding-right, 4px);
@ -74,7 +74,7 @@
> .puzzle { > .puzzle {
width: 100%; width: 100%;
@include S(height, 120px); @include S(height, 90px);
background: #f3f3f8; background: #f3f3f8;
@include S(border-radius, $globalBorderRadius); @include S(border-radius, $globalBorderRadius);
@ -112,6 +112,12 @@
white-space: nowrap; white-space: nowrap;
text-overflow: ellipsis; text-overflow: ellipsis;
overflow: hidden; overflow: hidden;
align-self: center;
justify-self: center;
width: 100%;
box-sizing: border-box;
@include S(padding, 2px, 5px);
@include S(height, 17px);
} }
> .icon { > .icon {
@ -119,8 +125,8 @@
grid-row: 2 / 3; grid-row: 2 / 3;
align-self: center; align-self: center;
justify-self: center; justify-self: center;
@include S(width, 70px); @include S(width, 45px);
@include S(height, 70px); @include S(height, 45px);
canvas { canvas {
width: 100%; width: 100%;
@ -154,8 +160,8 @@
color: #000; color: #000;
justify-self: start; justify-self: start;
font-weight: bold; font-weight: bold;
@include S(margin-right, 10px); @include S(margin-right, 5px);
@include S(padding-left, 14px); @include S(padding-left, 12px);
opacity: 0.7; opacity: 0.7;
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
@ -176,7 +182,7 @@
color: #000; color: #000;
justify-self: start; justify-self: start;
font-weight: bold; font-weight: bold;
@include S(padding-left, 14px); @include S(padding-left, 12px);
opacity: 0.7; opacity: 0.7;
@include DarkThemeInvert; @include DarkThemeInvert;
@ -202,11 +208,15 @@
> .stats, > .stats,
> .author, > .author,
> .title { > .title {
opacity: 0.5; opacity: 0.3;
} }
background: #fafafa; background: #fafafa;
@include DarkThemeOverride {
background: rgba(0, 0, 0, 0.05);
}
&::after { &::after {
content: ""; content: "";
position: absolute; position: absolute;

View File

@ -92,9 +92,11 @@ export class MetaBalancerBuilding extends MetaBuilding {
* @param {GameRoot} root * @param {GameRoot} root
*/ */
getAvailableVariants(root) { getAvailableVariants(root) {
let available = [defaultBuildingVariant]; const deterministic = root.gameMode.getIsDeterministic();
if (root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_merger)) { let available = deterministic ? [] : [defaultBuildingVariant];
if (!deterministic && root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_merger)) {
available.push(enumBalancerVariants.merger, enumBalancerVariants.mergerInverse); available.push(enumBalancerVariants.merger, enumBalancerVariants.mergerInverse);
} }

View File

@ -175,6 +175,11 @@ export class GameMode extends BasicSerializableObject {
return false; return false;
} }
/** @returns {boolean} */
getIsDeterministic() {
return false;
}
/** @returns {number | undefined} */ /** @returns {number | undefined} */
getFixedTickrate() { getFixedTickrate() {
return; return;

View File

@ -32,7 +32,7 @@ export class HUDPuzzleCompleteNotification extends BaseHUDPart {
this.root.signals.puzzleComplete.add(this.show, this); this.root.signals.puzzleComplete.add(this.show, this);
this.selectionLiked = null; this.selectionLiked = false;
this.selectionDifficulty = null; this.selectionDifficulty = null;
this.timeOfCompletion = 0; this.timeOfCompletion = 0;
} }
@ -69,20 +69,13 @@ export class HUDPuzzleCompleteNotification extends BaseHUDPart {
this.buttonLikeYes.classList.add("liked-yes"); this.buttonLikeYes.classList.add("liked-yes");
likeButtons.appendChild(this.buttonLikeYes); likeButtons.appendChild(this.buttonLikeYes);
this.trackClicks(this.buttonLikeYes, () => { this.trackClicks(this.buttonLikeYes, () => {
this.selectionLiked = true; this.selectionLiked = !this.selectionLiked;
this.updateState();
});
this.buttonLikeNo = document.createElement("button");
this.buttonLikeNo.classList.add("liked-no");
likeButtons.appendChild(this.buttonLikeNo);
this.trackClicks(this.buttonLikeNo, () => {
this.selectionLiked = false;
this.updateState(); this.updateState();
}); });
const stepDifficulty = makeDiv(this.elemContents, null, ["step", "stepDifficulty"]); const stepDifficulty = makeDiv(this.elemContents, null, ["step", "stepDifficulty"]);
makeDiv(stepDifficulty, null, ["title"], T.ingame.puzzleCompletion.titleRating); makeDiv(stepDifficulty, null, ["title"], T.ingame.puzzleCompletion.titleRating);
makeDiv(stepDifficulty, null, ["desc"], T.ingame.puzzleCompletion.titleRatingDesc);
const shapeContainer = makeDiv(stepDifficulty, null, ["shapes"]); const shapeContainer = makeDiv(stepDifficulty, null, ["shapes"]);
@ -135,7 +128,6 @@ export class HUDPuzzleCompleteNotification extends BaseHUDPart {
updateState() { updateState() {
this.buttonLikeYes.classList.toggle("active", this.selectionLiked === true); this.buttonLikeYes.classList.toggle("active", this.selectionLiked === true);
this.buttonLikeNo.classList.toggle("active", this.selectionLiked === false);
this.difficultyElements.forEach((canvas, index) => this.difficultyElements.forEach((canvas, index) =>
canvas.classList.toggle("active", index === this.selectionDifficulty) canvas.classList.toggle("active", index === this.selectionDifficulty)
); );
@ -165,7 +157,9 @@ export class HUDPuzzleCompleteNotification extends BaseHUDPart {
/** @type {PuzzlePlayGameMode} */ (this.root.gameMode) /** @type {PuzzlePlayGameMode} */ (this.root.gameMode)
.trackCompleted(this.selectionLiked, this.selectionDifficulty, Math.round(this.timeOfCompletion)) .trackCompleted(this.selectionLiked, this.selectionDifficulty, Math.round(this.timeOfCompletion))
.then(() => { .then(() => {
this.root.gameState.moveToState("PuzzleMenuState"); // this.root.gameState.moveToState("PuzzleMenuState");
this.visible = false;
this.cleanup();
}); });
} }

View File

@ -51,6 +51,14 @@ export class HUDPuzzlePlayMetadata extends BaseHUDPart {
: T.puzzleMenu.difficultyNotDetermined : T.puzzleMenu.difficultyNotDetermined
}</span> }</span>
</div> </div>
<div class="info rating">
<label>${T.ingame.puzzleMetadata.completionRate}</label>
<span>${
puzzle.meta.downloads > 10
? ((puzzle.meta.completions / puzzle.meta.downloads) * 100.0).toFixed(1) + "%"
: T.puzzleMenu.difficultyNotDetermined
}</span>
</div>
<div class="buttons"> <div class="buttons">
<button class="styledButton share">${T.ingame.puzzleEditorSettings.share}</button> <button class="styledButton share">${T.ingame.puzzleEditorSettings.share}</button>

View File

@ -88,6 +88,10 @@ export class PuzzleGameMode extends GameMode {
return 300; return 300;
} }
getIsDeterministic() {
return true;
}
/** @returns {boolean} */ /** @returns {boolean} */
getIsFreeplayAvailable() { getIsFreeplayAvailable() {
return true; return true;

View File

@ -569,17 +569,26 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
*/ */
process_GOAL(payload) { process_GOAL(payload) {
const goalComp = payload.entity.components.GoalAcceptor; const goalComp = payload.entity.components.GoalAcceptor;
const item = payload.items[0].item;
const now = this.root.time.now();
if (this.root.gameMode.getIsEditor()) { if (this.root.gameMode.getIsEditor()) {
// while playing in editor, assign the item // while playing in editor, assign the item
goalComp.item = payload.items[0].item; goalComp.item = payload.items[0].item;
goalComp.deliveryHistory.push({
item,
time: now,
});
} else {
// otherwise, make sure it is the same, otherwise reset
if (item.equals(goalComp.item)) {
goalComp.deliveryHistory.push({
item,
time: now,
});
} else {
goalComp.deliveryHistory = [];
}
} }
const now = this.root.time.now();
// push our new entry
goalComp.deliveryHistory.push({
item: payload.items[0].item,
time: now,
});
} }
} }

View File

@ -48,6 +48,7 @@
* shortKey: string; * shortKey: string;
* likes: number; * likes: number;
* downloads: number; * downloads: number;
* completions: number;
* difficulty: number | null; * difficulty: number | null;
* averageTime: number | null; * averageTime: number | null;
* title: string; * title: string;

View File

@ -21,6 +21,7 @@ const SAMPLE_PUZZLE = {
downloads: 0, downloads: 0,
likes: 0, likes: 0,
averageTime: 1, averageTime: 1,
completions: 1,
difficulty: null, difficulty: null,
title: "Level 1", title: "Level 1",
author: "verylongsteamnamewhichbreaks", author: "verylongsteamnamewhichbreaks",

View File

@ -621,8 +621,9 @@ ingame:
title: Puzzle Completed! title: Puzzle Completed!
titleLike: >- titleLike: >-
Please rate the puzzle: Click the heart if you liked the puzzle:
titleRating: How difficult did you find the puzzle? titleRating: How difficult did you find the puzzle?
titleRatingDesc: Your rating will help me to make you better suggestions in the future
buttonSubmit: Continue buttonSubmit: Continue
@ -638,6 +639,7 @@ ingame:
shortKey: Short Key shortKey: Short Key
rating: Difficulty score rating: Difficulty score
averageDuration: Avg. Duration averageDuration: Avg. Duration
completionRate: Completion rate
# All shop upgrades # All shop upgrades
shopUpgrades: shopUpgrades: