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

fix ci #8

Closed
wants to merge 11 commits into from
2 changes: 1 addition & 1 deletion .github/workflows/fossa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
run: mv .github/.fossa.yml .

- name: Cache Coursier cache
uses: coursier/cache-action@v6.4.0
uses: coursier/cache-action@v6.4.4

- name: Set up JDK 17
uses: coursier/setup-action@v1.3.0
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ your PR's comments if you don't).

Additionally, we have a few testing systems that stray from this general rule;
at the time of writing, these are for integration tests and language tests. You
can find more documentation about them [on this guide](gno/docs/testing-guide.md).
can find more documentation about them [on this guide](docs/testing-guide.md).

### Repository Structure

Expand Down
9 changes: 5 additions & 4 deletions contribs/gnodev/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ require (
github.com/fsnotify/fsnotify v1.7.0
github.com/gnolang/gno v0.0.0-00010101000000-000000000000
// github.com/gnolang/tx-archive v0.1.1
golang.org/x/term v0.15.0
golang.org/x/term v0.14.0
)

require (
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
github.com/btcsuite/btcd/btcutil v1.1.3 // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.1.1 // indirect
github.com/cockroachdb/apd v1.1.0 // indirect
github.com/cockroachdb/apd/v3 v3.2.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
github.com/dgraph-io/badger/v3 v3.2103.4 // indirect
Expand Down Expand Up @@ -50,11 +50,12 @@ require (
github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c // indirect
go.etcd.io/bbolt v1.3.8 // indirect
go.opencensus.io v0.22.5 // indirect
go.uber.org/multierr v1.10.0 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/crypto v0.15.0 // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/sys v0.14.0 // indirect
golang.org/x/tools v0.13.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
19 changes: 11 additions & 8 deletions contribs/gnodev/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion contribs/gnokeykc/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
github.com/btcsuite/btcd/btcutil v1.1.3 // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.1.1 // indirect
github.com/cockroachdb/apd v1.1.0 // indirect
github.com/cockroachdb/apd/v3 v3.2.1 // indirect
github.com/danieljoos/wincred v1.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions contribs/gnokeykc/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/standard-library.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ id: standard-library

# Gno Standard Library

When developing a realm in Gnolang, developers may utilize libraries in [stdlibs](https://github.com/gnolang/gno/tree/master/stdlibs). These are the core standard packages provided for Gnolang [Realms ](../explanation/realms.md)& [Packages](../explanation/packages.md).
When developing a realm in Gnolang, developers may utilize libraries in [stdlibs](https://github.com/gnolang/gno/tree/master/gnovm/stdlibs). These are the core standard packages provided for Gnolang [Realms ](../explanation/realms.md)& [Packages](../explanation/packages.md).

Libraries can be imported in a manner similar to how libraries are imported in Golang.

Expand Down
3 changes: 3 additions & 0 deletions examples/gno.land/p/demo/tamagotchi/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module gno.land/p/demo/tamagotchi

require gno.land/p/demo/ufmt v0.0.0-latest
175 changes: 175 additions & 0 deletions examples/gno.land/p/demo/tamagotchi/tamagotchi.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
package tamagotchi

import (
"time"

"gno.land/p/demo/ufmt"
)

// Tamagotchi structure
type Tamagotchi struct {
name string
hunger int
happiness int
health int
age int
maxAge int
sleepy int
created time.Time
lastUpdated time.Time
}

func New(name string) *Tamagotchi {
now := time.Now()
return &Tamagotchi{
name: name,
hunger: 50,
happiness: 50,
health: 50,
maxAge: 100,
lastUpdated: now,
created: now,
}
}

func (t *Tamagotchi) Name() string {
t.update()
return t.name
}

func (t *Tamagotchi) Hunger() int {
t.update()
return t.hunger
}

func (t *Tamagotchi) Happiness() int {
t.update()
return t.happiness
}

func (t *Tamagotchi) Health() int {
t.update()
return t.health
}

func (t *Tamagotchi) Age() int {
t.update()
return t.age
}

func (t *Tamagotchi) Sleepy() int {
t.update()
return t.sleepy
}

// Feed method for Tamagotchi
func (t *Tamagotchi) Feed() {
t.update()
if t.dead() {
return
}
t.hunger = bound(t.hunger-10, 0, 100)
}

// Play method for Tamagotchi
func (t *Tamagotchi) Play() {
t.update()
if t.dead() {
return
}
t.happiness = bound(t.happiness+10, 0, 100)
}

// Heal method for Tamagotchi
func (t *Tamagotchi) Heal() {
t.update()

if t.dead() {
return
}
t.health = bound(t.health+10, 0, 100)
}

func (t Tamagotchi) dead() bool { return t.health == 0 }

// Update applies changes based on the duration since the last update
func (t *Tamagotchi) update() {
if t.dead() {
return
}

now := time.Now()
if t.lastUpdated == now {
return
}

duration := now.Sub(t.lastUpdated)
elapsedMins := int(duration.Minutes())

t.hunger = bound(t.hunger+elapsedMins, 0, 100)
t.happiness = bound(t.happiness-elapsedMins, 0, 100)
t.health = bound(t.health-elapsedMins, 0, 100)
t.sleepy = bound(t.sleepy+elapsedMins, 0, 100)

// age is hours since created
t.age = int(now.Sub(t.created).Hours())
if t.age > t.maxAge {
t.age = t.maxAge
t.health = 0
}
if t.health == 0 {
t.sleepy = 0
t.happiness = 0
t.hunger = 0
}

t.lastUpdated = now
}

// Face returns an ASCII art representation of the Tamagotchi's current state
func (t *Tamagotchi) Face() string {
t.update()
return t.face()
}

func (t *Tamagotchi) face() string {
switch {
case t.health == 0:
return "😵" // dead face
case t.health < 30:
return "😷" // sick face
case t.happiness < 30:
return "😢" // sad face
case t.hunger > 70:
return "😫" // hungry face
case t.sleepy > 70:
return "😴" // sleepy face
default:
return "😃" // happy face
}
}

// Markdown method for Tamagotchi
func (t *Tamagotchi) Markdown() string {
t.update()
return ufmt.Sprintf(`# %s %s

* age: %d
* hunger: %d
* happiness: %d
* health: %d
* sleepy: %d`,
t.name, t.Face(),
t.age, t.hunger, t.happiness, t.health, t.sleepy,
)
}

func bound(n, min, max int) int {
if n < min {
return min
}
if n > max {
return max
}
return n
}
Loading
Loading