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.
@@ -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
-
data/lib/petli/poop.rb DELETED
@@ -1,9 +0,0 @@
1
- module Petli
2
- class Poop < Tatty::Anim
3
- LOCATIONS = [[1,1], [1,4], [1,7], [11,1], [11,7], [20,1], [20,4], [20,7]]
4
- ANIMATION = ["ı ı ı\n༼ᵔ◡ᵔ༽", "ϟ ϟ ϟ\n༼ಠ益ಠ༽"]
5
- def initialize()
6
- super(ANIMATION)
7
- end
8
- end
9
- end