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 */
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) {
@ -130,6 +130,12 @@
align-items: center;
@include S(margin-bottom, 10px);
> .desc {
@include SuperSmallText;
opacity: 0.4;
@include S(margin-bottom, 4px);
}
> .shapes {
@include S(margin-top, 10px);
display: flex;

View File

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

View File

@ -92,9 +92,11 @@ export class MetaBalancerBuilding extends MetaBuilding {
* @param {GameRoot} 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);
}

View File

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

View File

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

View File

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

View File

@ -569,17 +569,26 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
*/
process_GOAL(payload) {
const goalComp = payload.entity.components.GoalAcceptor;
const item = payload.items[0].item;
const now = this.root.time.now();
if (this.root.gameMode.getIsEditor()) {
// while playing in editor, assign the 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;
* likes: number;
* downloads: number;
* completions: number;
* difficulty: number | null;
* averageTime: number | null;
* title: string;

View File

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

View File

@ -621,8 +621,9 @@ ingame:
title: Puzzle Completed!
titleLike: >-
Please rate the puzzle:
Click the heart if you liked 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
@ -638,6 +639,7 @@ ingame:
shortKey: Short Key
rating: Difficulty score
averageDuration: Avg. Duration
completionRate: Completion rate
# All shop upgrades
shopUpgrades: