This is the kernel for the P2PMMO game: Proof of Honor.
The core is transaction-based and headless meaning that you can send your action-blocks to a buddy and a perfect copy of your character appears in their world.
- it's written ontop of pico
- can use hyperswarm for multiplay
- is totally missing an UI - Please PR/or Issue if you build one!
Once every 24 hours a
Heromay
append 1 block of actions - each block
must end with either going to sleep at a tavern or death.
Initialize kernel and create a new character:
import{boot}from'poh'constkernel=awaitboot()constname='Duncan the peerless'constmemo='<Last words on death>'awaitkernel.createHero(name,memo)// character sheet is exposed as a reactive-storeconstunsub=kernel.$player(hero=>{console.log('current stats and inventory',hero)})unsub()Now that you have a kernel and a hero,
you can begin exploring,
maybe visit the town for some shopping:
import{I,// ItemsA// Areas}from'poh/db'constsession=awaitkernel.beginPVE()// walk to townawaitsession.travelTo(A.crossroads)awaitsession.travelTo(A.town)// Buy a daggerawaitsession.interact(0,'buy',I.dagger,1)// Check inventorykernel.$player(h=>console.log('Inventory',h.inventory))()// Equip the weaponawaitsession.use(I.dagger)Good, now we're ready for adventure!
// walk back to crossroadsawaitsession.travelTo(A.crossroads)// look for troubleconstencounter=awaitsession.explore(0)console.log('You encountered',encounter)If a the encounter is hostile, you'll be locked in session.state == 'battle'\
at which point you are forced to choose one of the following:
// Hit the critterresult=session.doBattle('attack')// Use a skill/spellresult=session.doBattle('cast','firebolt')// Attempt escaperesult=session.doBattle('run')Note: Each round you're allowed to use 1 item session.use(I.herb)before you commit your combat action via session.doBattle()
Once you're happy with your achievements it's time to save state and call it a day:
// goto area with tavern/bedawaitsession.travelTo(A.town)// sleepconst[diff]=awaitkernel.commitPVE()console.log('gold, xp and stats gained',diff)note: k.commitPVE() broadcasts your character to the network
if kernel was booted with swarm K = await boot(Hyperswarm)
Ok that's pretty much the gist of it;
But always keep an eye on:
kernel.$player(hero=>console.log('current exhaustion',hero.exhaustion))()because:
Checkout test.js:89'Express gameplay as functions' for a complete
implementation of gameplay.
Checkout testnet.js for multiplayer/w bots.
Prior attempt / version 0: PoH-2020
AGPL-version-3
Clarification:
- do whatever you wish with your UI / assets
- please PR patches and changes to kernel, so everyone can play the same game.
- no sublicensing. the license is the license.
All wrongs reversed 🄯 2024 Tony Ivanov - decentlabs