silkedit 0.1.4 → 0.1.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a7f3339a4438bd794c4ed860bba4216a0b4bb018fdaa570d72f66e69388e975a
4
- data.tar.gz: d4a14494a7d827fd61c91e48f3b98500fc9c072f5718da7e504a14fc7f0ecb4c
3
+ metadata.gz: d05ae384c578d0145ea95589e40baaff71f938ecf9e9e3d1abf64b42d5a7d34a
4
+ data.tar.gz: 95bd985c710fd438824af21275b55f569ca7833bb16b0414e1e55873e9b2ea72
5
5
  SHA512:
6
- metadata.gz: dc0d913626bbe4eb89b3b7d684642202ccbe02b73de78d5bfacf6cd11ed034a922e4c8011acb31a57b23c5f84b5d409babf7f91cb888462833783c47c3ac4134
7
- data.tar.gz: 5b4ee244c35db3d4eec09e6202f450f9681edfbec1a2c25d81ae3f27a3e3b724c9924dfbe78c3296cdeb8173ace4c698346943af8305550e67dac7e308e77ce9
6
+ metadata.gz: '09a35377f50b2b0ca8dc74151e5badbb17dd939145670eb14087ccc9755455e3cc0f2c52d08b04ae06b31b131271327b0da65001b736008c6d3fdbc94179a8f2'
7
+ data.tar.gz: f7993d5aafd4ca024f1ed247104607d2595176cbb971e28587f595c065c17770968b3e5f970b5b5d10452062ef2fc8035cddca13287ef7993ab82cd2f5d7456d
@@ -2,18 +2,73 @@ Rbcli.command 'cheat' do
2
2
  description 'Applies one or more cheats to the selected savefile'
3
3
  usage '<cheat1> <cheat2> <cheat3>...'
4
4
  parameter :list, 'List all cheats', type: :bool, default: false
5
+ # parameter :force, "Force application of a cheat even when requirements aren't met. Additional changes may be made to your savegave.", type: :bool, default: false
5
6
  action do |opts, params, args, config, env|
6
7
  s = Silkedit::Savegame::SaveFile.new(:silksong, opts[:savenum])
7
8
  s.load_from_dat
8
9
  c = Silkedit::Cheat::Engine.new(s.data)
9
- selected_cheats = args.map { |arg| arg.downcase }.select { |cht| c.cheat_exists?(cht) }
10
- if params[:list] || selected_cheats.empty?
11
- Rbcli.log.info "Cheats: \n" + c.list_cheats.map(&:to_s).join("\n")
12
- else
13
- selected_cheats.each { |cht| c.apply_cheat(cht) }
14
- s.direct_backup
15
- s.save_to_dat
16
- Rbcli.log.info "applied cheats: #{selected_cheats.join(', ')}"
10
+
11
+ display_simple_list = lambda do |list, cols|
12
+ max_length = list.map(&:length).max
13
+ display_set = []
14
+ rows = (list.length / cols.to_f).ceil
15
+ row_idx = 0
16
+ max_rows = rows - 1
17
+ list.length.times do |i|
18
+ display_set[row_idx] ||= []
19
+ display_set[row_idx] << list[i]
20
+ row_idx += 1
21
+ row_idx = 0 if row_idx > max_rows
22
+ end
23
+ display_set.map { |row| row.map { |z| z.ljust(max_length) }.join(' ') }.join("\n")
17
24
  end
25
+
26
+ if args.empty? || params[:list]
27
+ Rbcli.log.info 'Cheats:'
28
+ Rbcli.log.info display_simple_list.call(c.list_cheats, 5)
29
+ Rbcli.exit(0)
30
+ end
31
+
32
+ changes = args.map do |cht|
33
+ cht = cht.downcase
34
+ status = c.apply_cheat(cht)
35
+ case status
36
+ when :no_cheat
37
+ Rbcli.log.warn "Could not apply cheat #{cht}: Cheat does not exist"
38
+ Rbcli.log.info 'Did you mean one of these?'
39
+ possible_cheats = c.list_cheats.select { |cheat| cheat.include?(cht) }
40
+ Rbcli.log.info display_simple_list.call(possible_cheats, 5)
41
+ nil
42
+ when :failed_act_check
43
+ Rbcli.log.warn "Could not apply cheat #{cht.colorize(:red)}: The player is in the wrong act. Use --(f)orce to override."
44
+ nil
45
+ when :failed_soft_reqs
46
+ Rbcli.log.warn "Could not apply cheat #{cht.colorize(:red)}: Soft requirements not met. Use --(f)orce to apply the required changes."
47
+ nil
48
+ when :failed_hard_reqs
49
+ Rbcli.log.error "Could not apply cheat #{cht.colorize(:red)}: Hard requirements not met. Applying the cheat would cause in-game errors."
50
+ nil
51
+ when :success
52
+ Rbcli.log.info " Success!".colorize(:green)
53
+ cht
54
+ else
55
+ raise "Unknown status: #{status}"
56
+ end
57
+ end
58
+
59
+ if changes.empty?
60
+ Rbcli.log.info ''
61
+ Rbcli.log.info 'No cheats applied'
62
+ Rbcli.exit(0)
63
+ end
64
+
65
+ if changes.include?(nil)
66
+ Rbcli.log.info ''
67
+ Rbcli.log.info 'Some cheats failed to apply. Discarding changes.'
68
+ Rbcli.exit(0)
69
+ end
70
+
71
+ s.direct_backup
72
+ s.save_to_dat
18
73
  end
19
74
  end
@@ -1,25 +1,26 @@
1
1
  Rbcli.command 'zone' do
2
2
  description 'Zones the character to a different respawn point'
3
3
  usage '<zone> (--(f)orce)'
4
- parameter :force, 'Force select a spawn point even when requirements are not met. Changes may be made to your savegave.', type: :bool, default: false
5
4
  parameter :list, 'Display the full list of zones to select from', type: :bool, default: false
5
+ parameter :force, 'Force select a spawn point even when requirements are not met. Changes may be made to your savegave.', type: :bool, default: false
6
6
  action do |opts, params, args, config, env|
7
7
  s = Silkedit::Savegame::SaveFile.new(:silksong, opts[:savenum])
8
8
  s.load_from_dat
9
9
  c = Silkedit::Cheat::Engine.new(s.data)
10
10
 
11
- display_simple_zone_list = lambda do |list, cols|
11
+ display_simple_list = lambda do |list, cols|
12
+ max_length = list.map(&:length).max
12
13
  display_set = []
13
- rows = (c.list_shortcuts.length / cols.to_f).ceil
14
+ rows = (list.length / cols.to_f).ceil
14
15
  row_idx = 0
15
16
  max_rows = rows - 1
16
- c.list_shortcuts.length.times do |i|
17
+ list.length.times do |i|
17
18
  display_set[row_idx] ||= []
18
- display_set[row_idx] << c.list_shortcuts.keys[i]
19
+ display_set[row_idx] << list[i]
19
20
  row_idx += 1
20
21
  row_idx = 0 if row_idx > max_rows
21
22
  end
22
- display_set.map { |row| row.map { |z| z.rjust(15) }.join(' ') }.join("\n")
23
+ display_set.map { |row| row.map { |z| z.ljust(max_length) }.join(' ') }.join("\n")
23
24
  end
24
25
 
25
26
  display_detailed_zone_list = lambda do |list|
@@ -33,7 +34,7 @@ Rbcli.command 'zone' do
33
34
 
34
35
  if args.empty? || params[:list]
35
36
  Rbcli.log.info 'Shortcuts:'
36
- Rbcli.log.info display_simple_zone_list.call(c.list_shortcuts, 5)
37
+ Rbcli.log.info display_simple_list.call(c.list_shortcuts.keys, 5)
37
38
  end
38
39
 
39
40
  if params[:list]
@@ -47,20 +48,20 @@ Rbcli.command 'zone' do
47
48
  status = c.zone_to(args.first, force_soft_reqs: params[:force], enforce_min_act: !params[:force])
48
49
  case status
49
50
  when :no_zone
50
- Rbcli.log.info "Could not zone to #{args.first}: Specified spawn point does not exist"
51
+ Rbcli.log.warn "Could not zone to #{args.first}: Specified spawn point does not exist"
51
52
  Rbcli.log.info 'Did you mean one of these?'
52
53
  possible_zones = c.list_zones.select { |zone| zone[:slug].include?(args.first) || !zone[:shortcut].nil? && zone[:shortcut].include?(args.first) }
53
- Rbcli.log.info display_detailed_zone_list.call(possible_zones)
54
+ Rbcli.log.info display_detailed_zone_list.call(possible_zones, 5)
54
55
  when :failed_act_check
55
- Rbcli.log.warn "Could not zone to #{args.first}: The player is in the wrong act. Use --(f)orce to override."
56
+ Rbcli.log.warn "Could not zone to #{args.first.colorize(:red)}: The player is in the wrong act. Use --(f)orce to override."
56
57
  when :failed_soft_reqs
57
- Rbcli.log.warn "Could not zone to #{args.first}: Soft requirements not met. Use --(f)orce to apply the required changes."
58
+ Rbcli.log.warn "Could not zone to #{args.first.colorize(:red)}: Soft requirements not met. Use --(f)orce to apply the required changes."
58
59
  when :failed_hard_reqs
59
- Rbcli.log.error "Could not zone to #{args.first}: Hard requirements not met. Zoning here would cause errors."
60
+ Rbcli.log.error "Could not zone to #{args.first.colorize(:red)}: Hard requirements not met. Zoning here would cause in-game errors."
60
61
  when :success
61
62
  s.direct_backup
62
63
  s.save_to_dat
63
- Rbcli.log.info "Zoned to #{args.first}"
64
+ Rbcli.log.info "Zoned to #{args.first.colorize(:green)}"
64
65
  else
65
66
  raise "Unknown status: #{status}"
66
67
  end
@@ -8,9 +8,8 @@ module Silkedit::Cheat
8
8
  end
9
9
 
10
10
  def apply_cheat(cheat, *args)
11
- return false unless cheat_exists?(cheat.to_s)
11
+ return :no_cheat unless cheat_exists?(cheat.to_s)
12
12
  self.send(cheat.to_sym, *args)
13
- true
14
13
  end
15
14
 
16
15
  def apply_cheats(cheats)
@@ -33,7 +33,8 @@ module Silkedit::Cheat
33
33
  end
34
34
 
35
35
  def max_everything
36
- %w[
36
+ backup_data = @data.dup
37
+ result = %w[
37
38
  max_health
38
39
  max_silk
39
40
  max_weapon
@@ -48,12 +49,31 @@ module Silkedit::Cheat
48
49
  give_consumables
49
50
  max_rosaries
50
51
  max_shards
51
- ].each { |cht| self.send(cht.to_sym) }
52
+ ].map { |cht| self.send(cht.to_sym) }
53
+ if result.all?(:success)
54
+ :success
55
+ else
56
+ @data = backup_data
57
+ result.reject { |r| r == :success }.first
58
+ end
52
59
  end
53
60
 
54
61
  def max_shards
55
62
  Rbcli.log.info 'Applying cheat max_shards', 'CHEATS'
56
63
  @data['playerData']['ShellShards'] = 400 + (@data['playerData']['ToolPouchUpgrades'] || 0) * 100
64
+ :success
65
+ end
66
+
67
+ def all_crests
68
+ cheatdata = Silkedit::Cheat::SilksongCheats.module_eval { @cheatdata }
69
+ Rbcli.log.info "Applying cheat all_crests", 'CHEATS'
70
+ Silkedit::Cheat.merge_cheat(@data, cheatdata['reference']['all_crests'], should_merge_arrays: true)
71
+ %w[CurrentCrestID PreviousCrestID].each do |equip|
72
+ %w[Hunter Hunter_v2].each do |hunter_crest_version|
73
+ @data['playerData'][equip] = 'Hunter_v3' if @data['playerData'][equip] == hunter_crest_version
74
+ end
75
+ end
76
+ :success
57
77
  end
58
78
 
59
79
  def all_crest_unlocks
@@ -68,11 +88,21 @@ module Silkedit::Cheat
68
88
  end
69
89
  crest['Data']['Slots'].each { |slot| slot['IsUnlocked'] = true }
70
90
  end
91
+ :success
92
+ end
93
+
94
+ def overcharge_tools
95
+ Rbcli.log.info "Applying cheat overcharge_tools", 'CHEATS'
96
+ @data['playerData']['Tools']['savedData'].each do |tool|
97
+ tool['Data']['AmountLeft'] = 1000
98
+ end
99
+ :success
71
100
  end
72
101
 
73
102
  def toggle_map_reveal
74
103
  @data['playerData']['mapAllRooms'] = !@data['playerData']['mapAllRooms']
75
104
  Rbcli.log.info "Full map reveal is #{@data['playerData']['mapAllRooms'] ? 'enabled' : 'disabled'}", 'CHEATS'
105
+ :success
76
106
  end
77
107
 
78
108
  def toggle_flea_reveal
@@ -80,6 +110,7 @@ module Silkedit::Cheat
80
110
  is_enabled = flea_keys.all? { |k| @data['playerData'][k] }
81
111
  flea_keys.each { |k| @data[k] = !is_enabled }
82
112
  Rbcli.log.info "Flea locations are #{is_enabled ? 'hidden' : 'revealed'} on map", 'CHEATS'
113
+ :success
83
114
  end
84
115
 
85
116
  def toggle_cloakless
@@ -110,18 +141,21 @@ module Silkedit::Cheat
110
141
  # @data['playerData']['slab_cloak_battle_completed'] = true
111
142
  @data['playerData']['IsSilkSpoolBroken'] = false
112
143
  end
144
+ :success
113
145
  end
114
146
 
115
147
  def toggle_permadeath_mode
116
148
  toggle = @data['playerData']['permadeathMode'] == 0
117
149
  Rbcli.log.info "Toggling permadeath mode #{toggle ? 'ON' : 'OFF'}", 'CHEATS'
118
150
  @data['playerData']['permadeathMode'] = toggle ? 1 : 0
151
+ :success
119
152
  end
120
153
 
121
154
  def toggle_fly_mode
122
155
  toggle = @data['playerData']['infiniteAirJump'] == false
123
156
  Rbcli.log.info "Toggling fly mode #{toggle ? 'ON' : 'OFF'}", 'CHEATS'
124
157
  @data['playerData']['infiniteAirJump'] = toggle ? true : false
158
+ :success
125
159
  end
126
160
  end
127
161
  end
@@ -25,7 +25,7 @@ module Silkedit::Cheat
25
25
  zonelist = Silkedit::Cheat::SilksongZoner.module_eval { @zonelist }
26
26
  shortcuts = Silkedit::Cheat::SilksongZoner.module_eval { @shortcuts }
27
27
  Rbcli.log.info "Zoning to #{zone}", 'ZONER'
28
- return self.zone_to(shortcuts[zone]) if shortcuts.key?(zone)
28
+ return self.zone_to(shortcuts[zone], force_soft_reqs: force_soft_reqs, enforce_min_act: enforce_min_act) if shortcuts.key?(zone)
29
29
  return :no_zone unless zonelist.find { |z| z['slug'] == zone }
30
30
  region, target = zone.split('.')
31
31
  Silkedit::Cheat.merge_cheat(