Skip to content

Commit

Permalink
Simplify, enhance output from get_stats
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-dray committed Oct 3, 2022
1 parent ec1ee89 commit 72bcc96
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 24 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: tamRgo
Title: Digital Pets in R
Version: 0.0.0.9003
Version: 0.0.0.9004
Authors@R: c(person("Matt", "Dray", , "mwdray@gmail.com", role = c("aut", "cre")),
person("Adriana", "De Palma", , , role = "ctb"))
Description: Store a digital pet on your computer and interact with it in your R
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@

# tamRgo 0.0.0.9004

* Simplified the output of `get_stats()` and included 'bars' for status values.

# tamRgo 0.0.0.9003

* Added a list of placeholder 'graphics' as internal data, with methods to call (i.e. `.get_pet_matrix()`) and print them (i.e. `.draw_pet()`), wrapped into the exported function `see_pet()` (towards #10).
Expand Down
17 changes: 7 additions & 10 deletions R/interact.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,14 @@ get_stats <- function() {

message(
"Characteristics",
"\n - Name: ", bp$characteristics$name,
"\n - Species: ", bp$characteristics$species,
"\n - Born: ", bp$characteristics$born,
"\n - Age: ", bp$characteristics$age,
"\nExperience",
"\n - Level: ", bp$experience$level,
"\n - XP: ", bp$experience$xp,
"\n Name: ", bp$characteristics$name,
"\n Species: ", bp$characteristics$species,
"\n Age: ", bp$characteristics$age,
"\n Level: ", bp$experience$level,
"\nStatus",
"\n - Happy: ", bp$status$happy, "/5",
"\n - Hungry: ", bp$status$hungry, "/5",
"\n - Dirty: ", bp$status$dirty, "/5"
"\n Happy: ", rep("", bp$status$happy), rep("", 5 - bp$status$happy),
"\n Hungry: ", rep("", bp$status$hungry), rep("", 5 - bp$status$hungry),
"\n Dirty: ", rep("", bp$status$dirty), rep("", 5 - bp$status$dirty)
)

}
Expand Down
36 changes: 25 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,17 @@ At any time you can see the latest statistics about your pet.
``` r
see_stats()
# Characteristics
# - Name: KEVIN
# - Species: Z
# - Born: 2022-09-20
# - Age: 0
# Experience
# - Level: 1
# - XP: 0
# Name: KEVIN
# Species: Z
# Age: 0
# Level: 1
# Status
# - Happy: 0/5
# - Hungry: 0/5
# - Dirty: 0/5
# Happy: □□□□□
# Hungry: □□□□□
# Dirty: □□□□□
```

These values will update over time. For example, the longer you wait to interact with your pet, the higher the 'hunger' status value will get. The pet will also accumulate experience points (XP) that contribute towards levelling up and visual transformations.
These values will update over time. For example, the longer you wait to interact with your pet, the higher the 'hunger' status value will get. The pet will also accumulate (hidden) experience points (XP) that contribute towards levelling up and visual transformations.

You can view in the console an image of your pet at any time. Their appearance will depend on their species.

Expand All @@ -87,6 +84,23 @@ play()
# 'Happy' status value is now 1/5
```

Let's recheck the 'happy' status.

``` r
see_stats()
# Characteristics
# Name: KEVIN
# Species: Z
# Age: 0
# Level: 1
# Status
# Happy: ■□□□□
# Hungry: □□□□□
# Dirty: □□□□□
```

Huzzah.

You can release your pet if you feel the time is right. This will delete its blueprint from your computer.

``` r
Expand Down
4 changes: 2 additions & 2 deletions data-raw/images.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ xm <- pixeltrix::click_pixels(8, 8)
ym <- pixeltrix::click_pixels(8, 8)
zm <- pixeltrix::click_pixels(8, 8)

matrix_to_sprite <- function(m, map = c("0" = "", "1" = ""), preview = TRUE) {
matrix_to_sprite <- function(m, states = c("0" = "", "1" = ""), preview = TRUE) {

mode(m) <- "character"
x <- matrix(map[m], nrow(m), ncol(m))
x <- matrix(states[m], nrow(m), ncol(m))

if (preview) {
for (i in seq(nrow(x))) {
Expand Down

0 comments on commit 72bcc96

Please sign in to comment.