Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initial example card game #27

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions apps/card-game/_dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
./tweego -w example.twee -o example.html
223 changes: 223 additions & 0 deletions apps/card-game/example.html

Large diffs are not rendered by default.

148 changes: 148 additions & 0 deletions apps/card-game/example.twee
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
:: StoryTitle
Card Game Example


:: StoryData
{
"ifid": "61485CD7-104E-4035-BB96-6CBB1050405D",
"format": "SugarCube",
"format-version": "2.36.1",
"start": "Start"
}


:: UserScript [script]
importScripts("https://cdn.tailwindcss.com");


:: UserStylesheet [stylesheet]
body {
background-color: white;
color: black;
}


:: StoryInit
<<set $allCards = {}>>

<<set $allCards["Sugar1"] = {
precondition: 'false',
description: "Do you want to feed more sugar to your people?",
accept: "<<set $happiness = $happiness + 2>><<set $health = $health - 3>><<goto 'CoreLoop'>>",
acceptExplanation: "Sugar is bad for you.",
reject: "<<goto 'CoreLoop'>>",
rejectExplanation: "Sugar is bad for you.",
}>>
<<set $allCards["Sugar2"] = {
precondition: 'false',
description: "Do you want to feed more sugar to your people?",
accept: "<<set $happiness = $happiness + 2>><<set $health = $health - 3>><<goto 'CoreLoop'>>",
acceptExplanation: "Sugar is bad for you.",
reject: "<<goto 'CoreLoop'>>",
rejectExplanation: "Sugar is bad for you.",
}>>
<<set $allCards["Sugar3"] = {
precondition: 'false',
description: "Do you want to feed more sugar to your people?",
accept: "<<set $happiness = $happiness + 2>><<set $health = $health - 3>><<goto 'CoreLoop'>>",
acceptExplanation: "Sugar is bad for you.",
reject: "<<goto 'CoreLoop'>>",
rejectExplanation: "Sugar is bad for you.",
}>>

<<set $allEvents = Object.keys($allCards)>>

<<set $cardArray = ['Sugar1']>>

<<set $intelligence = 5>>
<<set $health = 5>>
<<set $happiness = 5>>

<<set $explanation = 'undefined'>>
<<set $cardName = 'undefined'>>


:: Start

Hello, Mr. Governor! You are the boss. Do stuff.

Your population starts with 5 points in each category.

<<link "Start Game" "CoreLoop">><</link>>


:: CoreLoop
<<nobr>>
/* TODO: what to do if the available cards are empty? check a condition and win/lose? */

<<if $health <= 0 || $happiness <= 0 || $intelligence <= 0>>
<<goto 'GameOver'>>
<</if>>

<<if $allEvents.length === 0>>
<<goto 'Won'>>
<</if>>

<<if $explanation == 'undefined'>>
<<if $cardName != 'undefined'>>
<<set $allEvents.delete($cardName)>>
<</if>>

<<set $cardName = $cardArray.pluck()>> /* Pull a random card name from the deck. */

<<for eval($allCards[$cardName].precondition)>> /* Test the card. */
<<set $cardArray.push($cardName)>> /* Put the card back in the deck. */
<<set $cardName = $cardArray.pluck()>> /* Keep looking for a valid card. */
<</for>>
<</if>>

<<if $explanation != 'undefined'>>
<<set $cardArray.push($allEvents.random())>> /* Add a random event to the deck. */
<</if>>

<div>
<div class="flex flex-row justify-between bg-slate-100 px-4 py-2">
<div>INT: $intelligence/10</div>
<div>HEL: $health/10</div>
<div>HAP: $happiness/10</div>
</div>

<div class="p-8 rounded-xl border border-solid border-slate-500 shadow-xl bg-slate-200 mt-4 w-[300px] h-[400px] mx-auto flex flex-col justify-between">
<<if $explanation == 'undefined'>>
<div>
<<print $allCards[$cardName].description>>
</div>
<div class="flex flex-row justify-between">
<div class="text-green-600">
<<link "Accept">><<set $explanation = 'acceptExplanation'>><<run $.wiki($allCards[$cardName].accept)>><</link>>
</div>
<div class="text-red-600">
<<link "Reject">><<set $explanation = 'rejectExplanation'>><<run $.wiki($allCards[$cardName].reject)>><</link>>
</div>
</div>
<</if>>

<<if $explanation != 'undefined'>>
<div>
<<print $allCards[$cardName][$explanation]>>
</div>
<div class="flex flex-row justify-between">
<div>
</div>
<div class="text-green-600">
<<link "Next">><<set $explanation = 'undefined'>><<goto 'CoreLoop'>><</link>>
</div>
</div>
<</if>>
</div>
</div>
<</nobr>>

:: GameOver

THE END!


:: Won

Congratulations, you won!
21 changes: 21 additions & 0 deletions apps/card-game/storyformats/chapbook-1/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2018-9 Chris Klimas

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
1 change: 1 addition & 0 deletions apps/card-game/storyformats/chapbook-1/format.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions apps/card-game/storyformats/chapbook-1/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions apps/card-game/storyformats/harlowe-1/format.js

Large diffs are not rendered by default.

78 changes: 78 additions & 0 deletions apps/card-game/storyformats/harlowe-1/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions apps/card-game/storyformats/harlowe-2/format.js

Large diffs are not rendered by default.

78 changes: 78 additions & 0 deletions apps/card-game/storyformats/harlowe-2/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions apps/card-game/storyformats/harlowe-3/format.js

Large diffs are not rendered by default.

Loading