mirror of
https://gitlab.com/lecarore/breakout71.git
synced 2025-04-20 04:05:06 -04:00
wip
This commit is contained in:
parent
e78021ff83
commit
156c060b96
4 changed files with 51 additions and 39 deletions
32
dist/index.html
vendored
32
dist/index.html
vendored
File diff suppressed because one or more lines are too long
|
@ -521,7 +521,7 @@
|
||||||
{
|
{
|
||||||
"name": "icon:picky_eater",
|
"name": "icon:picky_eater",
|
||||||
"size": 8,
|
"size": 8,
|
||||||
"bricks": "rtrtrtrttrtrtrtrrtrtrtrt____________________t_____________WWWW",
|
"bricks": "_rrr_______ry_____ryy_____r_y______yyy______________y_____WWWW__",
|
||||||
"svg": null
|
"svg": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -594,7 +594,7 @@
|
||||||
{
|
{
|
||||||
"name": "A",
|
"name": "A",
|
||||||
"size": 7,
|
"size": 7,
|
||||||
"bricks": "___t_____ttt___t___t__t___t_tttttttt_____tt_____t",
|
"bricks": "__ttt___ttttt_ttt_ttttt___ttttttttttt___tttt___tt",
|
||||||
"svg": null
|
"svg": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,8 +13,7 @@ const rawLevelsList = _rawLevelsList as RawLevel[];
|
||||||
export const appVersion = _appVersion as string;
|
export const appVersion = _appVersion as string;
|
||||||
|
|
||||||
export const icons = {} as { [k: string]: string };
|
export const icons = {} as { [k: string]: string };
|
||||||
|
export const allLevelsAndIcons = rawLevelsList
|
||||||
export const allLevels = rawLevelsList
|
|
||||||
.map((level, i) => {
|
.map((level, i) => {
|
||||||
const bricks = level.bricks
|
const bricks = level.bricks
|
||||||
.split("")
|
.split("")
|
||||||
|
@ -32,12 +31,15 @@ export const allLevels = rawLevelsList
|
||||||
svg: getLevelBackground(level),
|
svg: getLevelBackground(level),
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
.filter((l) => !l.name.startsWith("icon:"))
|
|
||||||
.map((l, li) => ({
|
.map((l, li) => ({
|
||||||
...l,
|
...l,
|
||||||
sortKey: ((Math.random() + 3) / 3.5) * l.bricksCount,
|
sortKey: ((Math.random() + 3) / 3.5) * l.bricksCount,
|
||||||
})) as Level[];
|
})) as Level[];
|
||||||
|
|
||||||
|
export const allLevels =
|
||||||
|
allLevelsAndIcons.filter((l) => !l.name.startsWith("icon:"))
|
||||||
|
|
||||||
|
|
||||||
export const upgrades = rawUpgrades.map((u) => ({
|
export const upgrades = rawUpgrades.map((u) => ({
|
||||||
...u,
|
...u,
|
||||||
icon: icons["icon:" + u.id],
|
icon: icons["icon:" + u.id],
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { GameState, RunParams } from "./types";
|
import {GameState, PerkId, RunParams} from "./types";
|
||||||
import { allLevels, upgrades } from "./loadGameData";
|
import {allLevels, allLevelsAndIcons, upgrades} from "./loadGameData";
|
||||||
import {
|
import {
|
||||||
defaultSounds,
|
defaultSounds,
|
||||||
getHighScore,
|
getHighScore,
|
||||||
|
@ -15,15 +15,17 @@ import { getHistory } from "./gameOver";
|
||||||
import { getTotalScore } from "./settings";
|
import { getTotalScore } from "./settings";
|
||||||
import { isStartingPerk } from "./startingPerks";
|
import { isStartingPerk } from "./startingPerks";
|
||||||
|
|
||||||
export function getRunLevels(params: RunParams) {
|
export function getRunLevels(params: RunParams, randomGift:PerkId|undefined) {
|
||||||
const history = getHistory();
|
const history = getHistory();
|
||||||
const unlocked = allLevels.filter(
|
const unlocked = allLevels.filter(
|
||||||
(l, li) => !reasonLevelIsLocked(li, history, false),
|
(l, li) => !reasonLevelIsLocked(li, history, false),
|
||||||
);
|
);
|
||||||
|
|
||||||
const firstLevel = params?.level
|
|
||||||
? unlocked.filter((l) => l.name === params?.level)
|
const firstLevel = (params?.level && unlocked.filter((l) => l.name === params?.level))
|
||||||
: [];
|
|| (
|
||||||
|
randomGift && allLevelsAndIcons.filter(l=>l.name=='icon:'+randomGift)
|
||||||
|
) || [];
|
||||||
|
|
||||||
const restInRandomOrder = unlocked
|
const restInRandomOrder = unlocked
|
||||||
.filter((l) => l.name !== params?.level)
|
.filter((l) => l.name !== params?.level)
|
||||||
|
@ -36,10 +38,24 @@ export function getRunLevels(params: RunParams) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function newGameState(params: RunParams): GameState {
|
export function newGameState(params: RunParams): GameState {
|
||||||
const runLevels = getRunLevels(params);
|
const highScore= getHighScore()
|
||||||
|
|
||||||
const perks = { ...makeEmptyPerksMap(upgrades), ...(params?.perks || {}) };
|
const perks = { ...makeEmptyPerksMap(upgrades), ...(params?.perks || {}) };
|
||||||
|
|
||||||
|
let randomGift:PerkId|undefined =undefined
|
||||||
|
if (!sumOfValues(perks)) {
|
||||||
|
|
||||||
|
const giftable = upgrades.filter((u) => highScore >= u.threshold && !u.requires && isStartingPerk(u));
|
||||||
|
|
||||||
|
randomGift =
|
||||||
|
(isOptionOn("easy") && "slow_down") ||
|
||||||
|
giftable[Math.floor(Math.random() * giftable.length)].id;
|
||||||
|
|
||||||
|
perks[randomGift] = 1;
|
||||||
|
}
|
||||||
|
const runLevels = getRunLevels(params,randomGift);
|
||||||
|
console.log(randomGift, params,runLevels)
|
||||||
|
|
||||||
const gameState: GameState = {
|
const gameState: GameState = {
|
||||||
runLevels,
|
runLevels,
|
||||||
level: runLevels[0],
|
level: runLevels[0],
|
||||||
|
@ -69,7 +85,7 @@ export function newGameState(params: RunParams): GameState {
|
||||||
lastScoreIncrease: -1000,
|
lastScoreIncrease: -1000,
|
||||||
lastExplosion: -1000,
|
lastExplosion: -1000,
|
||||||
lastBrickBroken: 0,
|
lastBrickBroken: 0,
|
||||||
highScore: getHighScore(),
|
highScore,
|
||||||
balls: [],
|
balls: [],
|
||||||
ballsColor: "#FFFFFF",
|
ballsColor: "#FFFFFF",
|
||||||
bricks: [],
|
bricks: [],
|
||||||
|
@ -117,18 +133,8 @@ export function newGameState(params: RunParams): GameState {
|
||||||
};
|
};
|
||||||
resetBalls(gameState);
|
resetBalls(gameState);
|
||||||
|
|
||||||
if (!sumOfValues(gameState.perks)) {
|
|
||||||
const giftable = getPossibleUpgrades(gameState).filter((u) =>
|
|
||||||
isStartingPerk(u),
|
|
||||||
);
|
|
||||||
const randomGift =
|
|
||||||
(isOptionOn("easy") && "slow_down") ||
|
|
||||||
giftable[Math.floor(Math.random() * giftable.length)].id;
|
|
||||||
perks[randomGift] = 1;
|
|
||||||
dontOfferTooSoon(gameState, randomGift);
|
|
||||||
}
|
|
||||||
for (let perk of upgrades) {
|
for (let perk of upgrades) {
|
||||||
if (gameState.perks[perk.id]) {
|
if (perks[perk.id]) {
|
||||||
dontOfferTooSoon(gameState, perk.id);
|
dontOfferTooSoon(gameState, perk.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue