Implemented selling

This commit is contained in:
thepaperpilot 2023-02-20 00:43:27 -06:00
parent caa3783c4b
commit 0f537bbac5
4 changed files with 65 additions and 9 deletions

View file

@ -51,6 +51,7 @@
height: 16vmin; height: 16vmin;
cursor: pointer; cursor: pointer;
filter: drop-shadow(2px 4px 6px black); filter: drop-shadow(2px 4px 6px black);
margin-right: 0;
} }
.waiting { .waiting {
@ -186,6 +187,20 @@
position: absolute; position: absolute;
} }
.bottom-row {
width: 90%;
}
.bottom-row .row {
width: 100%;
align-items: center;
}
.bottom-row .button {
font-size: 4vmin;
padding: 4vmin;
}
@media (orientation: portrait) { @media (orientation: portrait) {
.teams-container { .teams-container {
flex-direction: column; flex-direction: column;

View file

@ -537,15 +537,38 @@ export const main = createLayer("main", function (this: BaseLayer) {
{findingMatch.value ? ( {findingMatch.value ? (
<div class="waiting">Finding opposing team...</div> <div class="waiting">Finding opposing team...</div>
) : ( ) : (
<img <Row class="bottom-row">
class="startStream" {selectedCharacter.value == null ? null : (
draggable="false" <button
onClick={() => { class="button"
emit("stream"); onDragover={e => e.preventDefault()}
findingMatch.value = true; onClick={() => emit("sell", selectedCharacter.value!)}
}} onDrop={() => emit("sell", selectedCharacter.value!)}
src={startStream} >
/> Sell
</button>
)}
{selectedShopItem.value == null ? null : (
<button
class="button"
onDragover={e => e.preventDefault()}
onClick={() => emit("freeze", selectedShopItem.value!)}
onDrop={() => emit("freeze", selectedShopItem.value!)}
>
Freeze
</button>
)}
<div style="flex-grow: 1" />
<img
class="startStream"
draggable="false"
onClick={() => {
emit("stream");
findingMatch.value = true;
}}
src={startStream}
/>
</Row>
)} )}
{render(particles)} {render(particles)}
</div> </div>

View file

@ -184,6 +184,20 @@ function setupSocket(socket: Socket<ServerToClientEvents, ClientToServerEvents>)
main.playClicked.value = false; main.playClicked.value = false;
setTimeout(main.prepareMove, 1000); setTimeout(main.prepareMove, 1000);
}); });
socket.on("sell", index => {
const member = main.team.value[index]!;
let level;
if (member.exp >= 6) {
level = 3;
} else if (member.exp >= 3) {
level = 2;
} else {
level = 1;
}
main.gold.value += level;
main.team.value[index] = null;
poof(`team-char-${index}`);
});
} }
declare module "game/settings" { declare module "game/settings" {

4
src/data/types.d.ts vendored
View file

@ -40,12 +40,16 @@ interface ServerToClientEvents {
}, },
outcome: BattleOutcome outcome: BattleOutcome
) => void; ) => void;
freeze: (index: number) => void;
sell: (index: number) => void;
} }
interface ClientToServerEvents { interface ClientToServerEvents {
buy: (shopIndex: number, teamIndex: number) => void; buy: (shopIndex: number, teamIndex: number) => void;
move: (index: number, otherIndex: number) => void; move: (index: number, otherIndex: number) => void;
merge: (index: number, otherIndex: number) => void; merge: (index: number, otherIndex: number) => void;
freeze: (index: number) => void;
sell: (index: number) => void;
reroll: () => void; reroll: () => void;
stream: () => void; stream: () => void;
newTurn: () => void; newTurn: () => void;