petli 0.0.3 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +5 -4
- data/LICENSE +1 -1
- data/README.md +4 -1
- data/bin/anim +24 -0
- data/bin/bootstrap.rb +3 -0
- data/bin/console +1 -1
- data/bin/petli +14 -12
- data/data/adult/001_diddly.txtanim +91 -0
- data/data/adult/002_kirby.txtanim +91 -0
- data/data/adult/003_tama.txtanim +85 -0
- data/data/adult/004_big.txtanim +62 -0
- data/data/adult/005_angel.txtanim +91 -0
- data/data/death.txtanim +9 -0
- data/data/hatch.txtanim +8 -0
- data/data/infant/001_baby.txtanim +80 -0
- data/data/poop.txtanim +6 -0
- data/data/sleep.txtanim +16 -0
- data/data/teen/001_baloop.txtanim +91 -0
- data/data/teen/002_roboty.txtanim +91 -0
- data/lib/petli/pet/animation.rb +94 -0
- data/lib/petli/pet/death.rb +45 -0
- data/lib/petli/pet/food.rb +45 -0
- data/lib/petli/pet/happy.rb +34 -0
- data/lib/petli/pet.rb +17 -119
- data/lib/petli/stages/base.rb +39 -14
- data/lib/petli/stages/dice.rb +8 -6
- data/lib/petli/stages/feed.rb +9 -9
- data/lib/petli/stages/guess.rb +7 -5
- data/lib/petli/stages/main.rb +7 -8
- data/lib/petli/stages/play.rb +5 -7
- data/lib/petli/version.rb +1 -1
- data/lib/petli/watch.rb +5 -0
- data/lib/petli.rb +9 -4
- data/lib/tatty/anim.rb +48 -6
- data/lib/tatty/atlas.rb +78 -0
- data/lib/tatty/stage.rb +3 -0
- data/lib/tatty.rb +3 -4
- data/petli.gemspec +2 -2
- metadata +26 -12
- data/data/character.json +0 -40
- data/data/face_ref +0 -73
- data/lib/petli/animator.rb +0 -137
- data/lib/petli/poop.rb +0 -9
data/lib/petli/animator.rb
DELETED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
module Petli
|
|
2
|
-
require 'json'
|
|
3
|
-
|
|
4
|
-
class Animator
|
|
5
|
-
ANIMATIONS = {
|
|
6
|
-
egg: [" _\n / \\\n \\_/", " _\n((/ \\\n \\_/))", " _\n / \\))\n((\\_/"]*5,
|
|
7
|
-
egg_crack: [" _\n/ \\\n\\_‚/"," _\n/ \\\n\\_¡/"," _\n/ \\\n\\_¦/"," _\n/ ¡\\\n\\_ϟ/"," _\n/ ¦\\\n\\_ϟ/"," _\n/ ϟ\\\n\\_ϟ/","\n/ ϟ\\\n\\_ϟ/"," ☁\n/ ϟ\\\n\\_ϟ/"],
|
|
8
|
-
stand: ["\n\nahe m eha\n", "\n\nahe m eha\n"],
|
|
9
|
-
left: ["\n\nahe m e ha\n", "\n\nahe m e ha\n"],
|
|
10
|
-
right: ["\n\nah e m eha\n", "\n\nah e m eha\n"],
|
|
11
|
-
item: ["\n\nahe m eha fff\n", "\n\nahe m eha fff\n", "\n\nahe m eha fff\n", "\n\nahe m eha fff\n"],
|
|
12
|
-
eat: ["\n\nahe m eha fff\n", "\n\nahe m eha ff\n", "\n\nahe m eha ff\n", "\n\nahe m eha f\n", "\n\nahe m eha f\n", "\n\nahe m eha\n"],
|
|
13
|
-
walk: ["\n\n ahe m eha\n", "\n\nahe m e ha\n", "\n\nahe m eha\n", "\n\nah e m eha\n"],
|
|
14
|
-
hop: ["\n\n ahe m eha\n", "\nahe m e ha\n\n", "\n\nahe m e ha\n", "\n\nahe m eha\n", "\nah e m eha\n\n", "\n\nah e m eha\n"],
|
|
15
|
-
death: [" ┌───┐ \n │ ☠ │ \n │ │ \n ```````", " ┌───┐ \n │ ☠ │ \n │ │ \n '''''''"],
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
attr_writer :mood
|
|
19
|
-
attr_reader :action
|
|
20
|
-
|
|
21
|
-
def initialize(hatching:, mood:, action: :walk)
|
|
22
|
-
@frame = 0
|
|
23
|
-
@food = :bread
|
|
24
|
-
@mood = mood
|
|
25
|
-
@action = action
|
|
26
|
-
if hatching
|
|
27
|
-
@mood_stack = [:mezmerized, :mezmerized, :mezmerized, :mezmerized]
|
|
28
|
-
@action_stack = [:egg, :egg_crack, :stand, :stand]
|
|
29
|
-
else
|
|
30
|
-
@mood_stack = []
|
|
31
|
-
@action_stack = []
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def step
|
|
36
|
-
add_frame
|
|
37
|
-
leftarm, rightarm = getit(:arms, 2)
|
|
38
|
-
lefteye, righteye = getit(:eyes, 2)
|
|
39
|
-
mouth = getit(:mouth)
|
|
40
|
-
lefthead, righthead = getit(:head, 2)
|
|
41
|
-
[leftarm,lefthead,lefteye,mouth,righteye,righthead,rightarm]
|
|
42
|
-
|
|
43
|
-
food_peices = food.split('')
|
|
44
|
-
|
|
45
|
-
ANIMATIONS[action][frame]
|
|
46
|
-
.sub('a', leftarm.to_s).sub('a', rightarm.to_s)
|
|
47
|
-
.sub('h', lefthead).sub('h', righthead)
|
|
48
|
-
.sub('e', lefteye).sub('e', righteye)
|
|
49
|
-
.sub('m', mouth)
|
|
50
|
-
.reverse
|
|
51
|
-
.sub('f', food_peices[2]).sub('f', food_peices[1]).sub('f', food_peices[0])
|
|
52
|
-
.reverse
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
def eat(food: :bread, &block)
|
|
56
|
-
@busy = true
|
|
57
|
-
@frame = 0
|
|
58
|
-
@food = food
|
|
59
|
-
@action_stack = [:item, :eat, :stand, :stand, :stand, :stand]
|
|
60
|
-
@mood_stack = [:mezmerized, :eating, :eating, :mezmerized, :mezmerized]
|
|
61
|
-
@on_complete = block
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
def celebrate
|
|
65
|
-
@action_stack = [:stand, :stand, :stand, :stand]
|
|
66
|
-
@mood_stack = [:mezmerized, :mezmerized, :mezmerized, :mezmerized]
|
|
67
|
-
@frame = 0
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
def embarass
|
|
71
|
-
@action_stack = [:stand, :stand, :stand, :stand]
|
|
72
|
-
@mood_stack = [:embarassed, :embarassed, :embarassed, :embarassed]
|
|
73
|
-
@frame = 0
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
def busy?
|
|
77
|
-
@busy
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
def action=(act)
|
|
81
|
-
@action = act
|
|
82
|
-
@frame = 0
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
def action
|
|
86
|
-
@action_stack.count > 0 ? @action_stack[0] : @action
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
def mood
|
|
90
|
-
@mood_stack.count > 0 ? @mood_stack[0] : @mood
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
private
|
|
94
|
-
|
|
95
|
-
def add_frame
|
|
96
|
-
frame_count = ANIMATIONS[action].count
|
|
97
|
-
@frame += 1
|
|
98
|
-
if frame == frame_count
|
|
99
|
-
@frame = 0
|
|
100
|
-
@action_stack.shift if @action_stack.count > 0
|
|
101
|
-
@mood_stack.shift if @mood_stack.count > 0
|
|
102
|
-
if @action_stack.count == 0 && @mood_stack.count == 0
|
|
103
|
-
@busy = false
|
|
104
|
-
@on_complete.call unless @on_complete.nil?
|
|
105
|
-
@on_complete = nil
|
|
106
|
-
end
|
|
107
|
-
end
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
def food
|
|
111
|
-
data[@food]
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
def frame # to control framerate
|
|
115
|
-
(@frame/3).ceil
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
def getit(part, vals=1)
|
|
119
|
-
mood_part = data[part][mood] || data[part][:default]
|
|
120
|
-
part_frame = frame % mood_part.count
|
|
121
|
-
result = mood_part[part_frame]
|
|
122
|
-
if vals == 2 && result.is_a?(String)
|
|
123
|
-
[result, result]
|
|
124
|
-
else
|
|
125
|
-
result
|
|
126
|
-
end
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
def data
|
|
130
|
-
@data ||= JSON.parse(
|
|
131
|
-
File.read(File.expand_path('../../data/character.json', __dir__)),
|
|
132
|
-
{:symbolize_names => true}
|
|
133
|
-
)
|
|
134
|
-
end
|
|
135
|
-
end
|
|
136
|
-
end
|
|
137
|
-
|