wxrcg 0.1.0
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.
- data/.gitignore +1 -0
- data/LICENSE +24 -0
- data/README.md +51 -0
- data/Rakefile +30 -0
- data/VERSION +1 -0
- data/bin/dm_screen +17 -0
- data/bin/stats +21 -0
- data/bin/weapon_add +24 -0
- data/config/database.yml +22 -0
- data/db/development.sqlite +0 -0
- data/db/development.sqlite3 +0 -0
- data/db/sqlite scripts/create_armours.sql +16 -0
- data/db/sqlite scripts/create_categories.sql +10 -0
- data/db/sqlite scripts/create_characters.sql +21 -0
- data/db/sqlite scripts/create_races.sql +9 -0
- data/db/sqlite scripts/create_weapons.sql +16 -0
- data/db/sqlite scripts/critical.sql +12 -0
- data/db/sqlite scripts/damage.sql +21 -0
- data/db/sqlite scripts/damage_type.sql +15 -0
- data/db/sqlite scripts/encumbrance_type.sql +10 -0
- data/db/sqlite scripts/training_type.sql +8 -0
- data/db/sqlite scripts/weapon_special_qualities_weapons.sql +17 -0
- data/db/test.sqlite +0 -0
- data/lib/character.old.rb +72 -0
- data/lib/controllers/character_controller.rb +35 -0
- data/lib/controllers/dm_screen_controller.rb +23 -0
- data/lib/controllers/weapon_controller.rb +37 -0
- data/lib/initdb.rb +27 -0
- data/lib/models/armour.rb +3 -0
- data/lib/models/character.rb +120 -0
- data/lib/models/critical.rb +11 -0
- data/lib/models/damage.rb +8 -0
- data/lib/models/damage_type.rb +3 -0
- data/lib/models/encumbrance_type.rb +3 -0
- data/lib/models/race.rb +3 -0
- data/lib/models/size.rb +4 -0
- data/lib/models/training_type.rb +3 -0
- data/lib/models/weapon.rb +59 -0
- data/lib/models/weapon_special_quality.rb +3 -0
- data/lib/views/abilities_frame.rb +285 -0
- data/lib/views/char_select_dialog.rb +60 -0
- data/lib/views/dm_screen_frame.rb +64 -0
- data/lib/views/weapon_screen_frame.rb +232 -0
- data/log/.keep_me +0 -0
- data/tests/armour_model_test.rb +10 -0
- data/tests/character_model_test.rb +10 -0
- data/tests/critical_model_test.rb +10 -0
- data/tests/damage_model_test.rb +10 -0
- data/tests/damage_type_model_test.rb +10 -0
- data/tests/encumbrance_type_model_test.rb +10 -0
- data/tests/race_model_test.rb +10 -0
- data/tests/size_model_test.rb +10 -0
- data/tests/training_type_model_test.rb +10 -0
- data/tests/weapon_model_test.rb +19 -0
- data/tests/weapon_special_quality_model_test.rb +10 -0
- metadata +141 -0
@@ -0,0 +1,120 @@
|
|
1
|
+
root = File.dirname(__FILE__)
|
2
|
+
require File.join(root, "race.rb")
|
3
|
+
require File.join(root, "armour.rb")
|
4
|
+
require File.join(root, "weapon.rb")
|
5
|
+
|
6
|
+
class Character < ActiveRecord::Base
|
7
|
+
belongs_to :race
|
8
|
+
belongs_to :armour
|
9
|
+
belongs_to :weapon
|
10
|
+
|
11
|
+
def after_initialize
|
12
|
+
self.str ||= 10
|
13
|
+
self.dex ||= 10
|
14
|
+
self.con ||= 10
|
15
|
+
self.int ||= 10
|
16
|
+
self.wis ||= 10
|
17
|
+
self.cha ||= 10
|
18
|
+
end
|
19
|
+
|
20
|
+
def stat(stat)
|
21
|
+
if self.race != nil then
|
22
|
+
s = eval(stat) + eval("@race.#{stat}_mod")
|
23
|
+
else
|
24
|
+
s = eval(stat)
|
25
|
+
end
|
26
|
+
if stat == self.floating_race_mod then s = s + 2 end
|
27
|
+
return s
|
28
|
+
end
|
29
|
+
|
30
|
+
def update_stats
|
31
|
+
self.str = self.str + @race.str_mod
|
32
|
+
self.dex = self.dex + @race.dex_mod
|
33
|
+
self.con = self.con + @race.con_mod
|
34
|
+
self.int = self.int + @race.int_mod
|
35
|
+
self.wis = self.wis + @race.wis_mod
|
36
|
+
self.cha = self.cha + @race.cha_mod
|
37
|
+
end
|
38
|
+
|
39
|
+
def mod(stat)
|
40
|
+
((stat(stat)-10)/2)
|
41
|
+
end
|
42
|
+
|
43
|
+
def race_mod(stat)
|
44
|
+
if self.race != nil then
|
45
|
+
rm = eval("@race.#{stat}_mod")
|
46
|
+
else
|
47
|
+
rm = 0
|
48
|
+
end
|
49
|
+
if stat == self.floating_race_mod then rm = rm + 2 end
|
50
|
+
return rm
|
51
|
+
end
|
52
|
+
|
53
|
+
def points(stat)
|
54
|
+
s = case eval(stat)
|
55
|
+
when 7 then -4
|
56
|
+
when 8 then -2
|
57
|
+
when 9 then -1
|
58
|
+
when 10 then 0
|
59
|
+
when 11 then 1
|
60
|
+
when 12 then 2
|
61
|
+
when 13 then 3
|
62
|
+
when 14 then 5
|
63
|
+
when 15 then 7
|
64
|
+
when 16 then 10
|
65
|
+
when 17 then 13
|
66
|
+
when 18 then 17
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def total_points
|
71
|
+
t = points("str") + points("dex") + points("con") + points("int") + points("wis") + points("cha")
|
72
|
+
end
|
73
|
+
|
74
|
+
def set_floating_race_mod(ability)
|
75
|
+
self.floating_race_mod = case ability
|
76
|
+
when "Strength" then "str"
|
77
|
+
when "Dexterity" then "dex"
|
78
|
+
when "Consitution" then "con"
|
79
|
+
when "Intelegence" then "int"
|
80
|
+
when "Wisdom" then "wis"
|
81
|
+
when "Charisma" then "cha"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def get_floating_race_mod
|
86
|
+
frm = case self.floating_race_mod
|
87
|
+
when "str" then "Strength"
|
88
|
+
when "dex" then "Dexterity"
|
89
|
+
when "con" then "Constitution"
|
90
|
+
when "int" then "Intelegence"
|
91
|
+
when "wis" then "Wisdom"
|
92
|
+
when "cha" then "Charisma"
|
93
|
+
else ""
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def ac
|
98
|
+
ac = 10 + mod(:dex) + armour.bonus
|
99
|
+
end
|
100
|
+
|
101
|
+
def touch
|
102
|
+
touch = 10 + mod(:dex)
|
103
|
+
end
|
104
|
+
|
105
|
+
def ff
|
106
|
+
ff = 10 + armour.bonus
|
107
|
+
end
|
108
|
+
|
109
|
+
def init
|
110
|
+
init = mod(:dex)
|
111
|
+
end
|
112
|
+
|
113
|
+
def attack_mod
|
114
|
+
if self.weapon.encumbrance_type.name == "Ranged" then
|
115
|
+
am = bab + mod(:dex)
|
116
|
+
else
|
117
|
+
am = bab + mod(:str)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
data/lib/models/race.rb
ADDED
data/lib/models/size.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
root = File.dirname(__FILE__)
|
2
|
+
require File.join(root,"training_type")
|
3
|
+
require File.join(root,"encumbrance_type")
|
4
|
+
require File.join(root,"damage")
|
5
|
+
require File.join(root,"damage_type")
|
6
|
+
require File.join(root,"critical")
|
7
|
+
require File.join(root,"size")
|
8
|
+
require File.join(root,"weapon_special_quality")
|
9
|
+
|
10
|
+
class Weapon < ActiveRecord::Base
|
11
|
+
belongs_to :character
|
12
|
+
belongs_to :training_type
|
13
|
+
belongs_to :encumbrance_type
|
14
|
+
belongs_to :damage
|
15
|
+
belongs_to :damage2, :class_name => "Damage"
|
16
|
+
belongs_to :damage_type
|
17
|
+
belongs_to :critical
|
18
|
+
belongs_to :size
|
19
|
+
has_and_belongs_to_many :weapon_special_qualities
|
20
|
+
|
21
|
+
def has_quality(quality)
|
22
|
+
weapon_special_qualities << quality
|
23
|
+
end
|
24
|
+
|
25
|
+
def has_quality?(quality)
|
26
|
+
qid = WeaponSpecialQuality.find_by_name(quality).id
|
27
|
+
x = false
|
28
|
+
x = true unless weapon_special_qualities.count(
|
29
|
+
:conditions => "'weapon_special_qualities_weapons'.weapon_special_quality_id = #{qid}"
|
30
|
+
) == 0
|
31
|
+
end
|
32
|
+
|
33
|
+
def specials
|
34
|
+
weapon_special_qualities.map{|x| x.name}.join(",")
|
35
|
+
end
|
36
|
+
|
37
|
+
def combined_damage
|
38
|
+
x = ""
|
39
|
+
x << damage.to_s
|
40
|
+
weapon_special_qualities.each {|wsq| if wsq.name == "Double" then x << "/" << damage2.to_s end}
|
41
|
+
return x
|
42
|
+
end
|
43
|
+
|
44
|
+
def fcost
|
45
|
+
s = ""
|
46
|
+
s << cost.to_s << "gp" unless cost == nil
|
47
|
+
end
|
48
|
+
|
49
|
+
def fweight
|
50
|
+
s = ""
|
51
|
+
s << weight.to_s << "lb" unless weight == nil
|
52
|
+
end
|
53
|
+
|
54
|
+
def frange
|
55
|
+
s = ""
|
56
|
+
s << range.to_s << "ft" unless range== nil
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
@@ -0,0 +1,285 @@
|
|
1
|
+
class WxRCG_frame < Wx::Frame
|
2
|
+
def initialize(race_list, character)
|
3
|
+
@character = character
|
4
|
+
super(nil, :title => "wxRuby Character Generator!")
|
5
|
+
@panel = Wx::Panel.new(self)
|
6
|
+
# Sizers
|
7
|
+
@grid_sizer = Wx::GridSizer.new(0,6,0,0)
|
8
|
+
@box_sizer = Wx::BoxSizer.new(Wx::VERTICAL)
|
9
|
+
|
10
|
+
#Name
|
11
|
+
@name_label = Wx::StaticText.new(self, -1, "Character Name")
|
12
|
+
@name_edit = Wx::TextCtrl.new(self, -1)
|
13
|
+
|
14
|
+
#Race Choice
|
15
|
+
@race_label = Wx::StaticText.new(self, -1, "Race")
|
16
|
+
@race_choice = Wx::Choice.new(self, -1)
|
17
|
+
#Set up Choices
|
18
|
+
choices = race_list
|
19
|
+
choices.each {|choice| @race_choice.append(choice.name)}
|
20
|
+
|
21
|
+
#Ability to Enhance
|
22
|
+
@ability_label = Wx::StaticText.new(self, -1, "Ability to Enhance")
|
23
|
+
@ability_choice = Wx::Choice.new(self, -1)
|
24
|
+
@ability_label.enable(false)
|
25
|
+
@ability_choice.enable(false)
|
26
|
+
#Set up Choices
|
27
|
+
choices = ["Strength", "Dexterity", "Consitution", "Intelegence", "Wisdom", "Charisma"]
|
28
|
+
choices.each {|choice| @ability_choice.append(choice)}
|
29
|
+
|
30
|
+
# Spin Controls
|
31
|
+
@str_spinctrl = Wx::SpinCtrl.new(self,:min => 7, :max => 18, :initial => 10)
|
32
|
+
@dex_spinctrl = Wx::SpinCtrl.new(self,:min => 7, :max => 18, :initial => 10)
|
33
|
+
@con_spinctrl = Wx::SpinCtrl.new(self,:min => 7, :max => 18, :initial => 10)
|
34
|
+
@int_spinctrl = Wx::SpinCtrl.new(self,:min => 7, :max => 18, :initial => 10)
|
35
|
+
@wis_spinctrl = Wx::SpinCtrl.new(self,:min => 7, :max => 18, :initial => 10)
|
36
|
+
@cha_spinctrl = Wx::SpinCtrl.new(self,:min => 7, :max => 18, :initial => 10)
|
37
|
+
|
38
|
+
# Save Button
|
39
|
+
@save_btn = Wx::Button.new(self,:label=>'Save')
|
40
|
+
|
41
|
+
# load Button
|
42
|
+
@load_btn = Wx::Button.new(self,:label=>'Load')
|
43
|
+
|
44
|
+
#Set up Labels
|
45
|
+
col_1_txt = Wx::StaticText.new(self,-1,"Ability")
|
46
|
+
col_2_txt = Wx::StaticText.new(self,-1,"Base Score")
|
47
|
+
col_3_txt = Wx::StaticText.new(self,-1,"Race Mod")
|
48
|
+
col_4_txt = Wx::StaticText.new(self,-1,"Total")
|
49
|
+
col_5_txt = Wx::StaticText.new(self,-1,"Ability Mod")
|
50
|
+
col_6_txt = Wx::StaticText.new(self,-1,"Points")
|
51
|
+
@str_ab_txt = Wx::StaticText.new(self,-1,"Strength")
|
52
|
+
@dex_ab_txt = Wx::StaticText.new(self,-1,"Dexterity")
|
53
|
+
@con_ab_txt = Wx::StaticText.new(self,-1,"Constitution")
|
54
|
+
@int_ab_txt = Wx::StaticText.new(self,-1,"Intelegence")
|
55
|
+
@wis_ab_txt = Wx::StaticText.new(self,-1,"Wisdom")
|
56
|
+
@cha_ab_txt = Wx::StaticText.new(self,-1,"Charisma")
|
57
|
+
@str_rm_txt = Wx::StaticText.new(self,-1,"0")
|
58
|
+
@dex_rm_txt = Wx::StaticText.new(self,-1,"0")
|
59
|
+
@con_rm_txt = Wx::StaticText.new(self,-1,"0")
|
60
|
+
@int_rm_txt = Wx::StaticText.new(self,-1,"0")
|
61
|
+
@wis_rm_txt = Wx::StaticText.new(self,-1,"0")
|
62
|
+
@cha_rm_txt = Wx::StaticText.new(self,-1,"0")
|
63
|
+
@str_to_txt = Wx::StaticText.new(self,-1,"")
|
64
|
+
@dex_to_txt = Wx::StaticText.new(self,-1,"")
|
65
|
+
@con_to_txt = Wx::StaticText.new(self,-1,"")
|
66
|
+
@int_to_txt = Wx::StaticText.new(self,-1,"")
|
67
|
+
@wis_to_txt = Wx::StaticText.new(self,-1,"")
|
68
|
+
@cha_to_txt = Wx::StaticText.new(self,-1,"")
|
69
|
+
@str_am_txt = Wx::StaticText.new(self,-1,"")
|
70
|
+
@dex_am_txt = Wx::StaticText.new(self,-1,"")
|
71
|
+
@con_am_txt = Wx::StaticText.new(self,-1,"")
|
72
|
+
@int_am_txt = Wx::StaticText.new(self,-1,"")
|
73
|
+
@wis_am_txt = Wx::StaticText.new(self,-1,"")
|
74
|
+
@cha_am_txt = Wx::StaticText.new(self,-1,"")
|
75
|
+
@str_po_txt = Wx::StaticText.new(self,-1,"")
|
76
|
+
@dex_po_txt = Wx::StaticText.new(self,-1,"")
|
77
|
+
@con_po_txt = Wx::StaticText.new(self,-1,"")
|
78
|
+
@int_po_txt = Wx::StaticText.new(self,-1,"")
|
79
|
+
@wis_po_txt = Wx::StaticText.new(self,-1,"")
|
80
|
+
@cha_po_txt = Wx::StaticText.new(self,-1,"")
|
81
|
+
@blank_txt = Wx::StaticText.new(self,-1,"")
|
82
|
+
@total_txt = Wx::StaticText.new(self,-1,"")
|
83
|
+
|
84
|
+
#Add everythig into the sizer
|
85
|
+
@box_sizer.add(@name_label,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
86
|
+
@box_sizer.add(@name_edit,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
87
|
+
@box_sizer.add(@race_label,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
88
|
+
@box_sizer.add(@race_choice,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
89
|
+
@box_sizer.add(@ability_label,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
90
|
+
@box_sizer.add(@ability_choice,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
91
|
+
@box_sizer.add(@grid_sizer)
|
92
|
+
@grid_sizer.add(col_1_txt,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
93
|
+
@grid_sizer.add(col_2_txt,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
94
|
+
@grid_sizer.add(col_3_txt,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
95
|
+
@grid_sizer.add(col_4_txt,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
96
|
+
@grid_sizer.add(col_5_txt,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
97
|
+
@grid_sizer.add(col_6_txt,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
98
|
+
# Str
|
99
|
+
@grid_sizer.add(@str_ab_txt,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
100
|
+
@grid_sizer.add(@str_spinctrl,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
101
|
+
@grid_sizer.add(@str_rm_txt,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
102
|
+
@grid_sizer.add(@str_to_txt,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
103
|
+
@grid_sizer.add(@str_am_txt,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
104
|
+
@grid_sizer.add(@str_po_txt,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
105
|
+
# dex
|
106
|
+
@grid_sizer.add(@dex_ab_txt,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
107
|
+
@grid_sizer.add(@dex_spinctrl,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
108
|
+
@grid_sizer.add(@dex_rm_txt,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
109
|
+
@grid_sizer.add(@dex_to_txt,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
110
|
+
@grid_sizer.add(@dex_am_txt,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
111
|
+
@grid_sizer.add(@dex_po_txt,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
112
|
+
# con
|
113
|
+
@grid_sizer.add(@con_ab_txt,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
114
|
+
@grid_sizer.add(@con_spinctrl,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
115
|
+
@grid_sizer.add(@con_rm_txt,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
116
|
+
@grid_sizer.add(@con_to_txt,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
117
|
+
@grid_sizer.add(@con_am_txt,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
118
|
+
@grid_sizer.add(@con_po_txt,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
119
|
+
# int
|
120
|
+
@grid_sizer.add(@int_ab_txt,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
121
|
+
@grid_sizer.add(@int_spinctrl,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
122
|
+
@grid_sizer.add(@int_rm_txt,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
123
|
+
@grid_sizer.add(@int_to_txt,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
124
|
+
@grid_sizer.add(@int_am_txt,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
125
|
+
@grid_sizer.add(@int_po_txt,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
126
|
+
# wis
|
127
|
+
@grid_sizer.add(@wis_ab_txt,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
128
|
+
@grid_sizer.add(@wis_spinctrl,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
129
|
+
@grid_sizer.add(@wis_rm_txt,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
130
|
+
@grid_sizer.add(@wis_to_txt,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
131
|
+
@grid_sizer.add(@wis_am_txt,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
132
|
+
@grid_sizer.add(@wis_po_txt,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
133
|
+
# cha
|
134
|
+
@grid_sizer.add(@cha_ab_txt,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
135
|
+
@grid_sizer.add(@cha_spinctrl,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
136
|
+
@grid_sizer.add(@cha_rm_txt,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
137
|
+
@grid_sizer.add(@cha_to_txt,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
138
|
+
@grid_sizer.add(@cha_am_txt,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
139
|
+
@grid_sizer.add(@cha_po_txt,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
140
|
+
# Total
|
141
|
+
@grid_sizer.add(@blank_txt,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
142
|
+
@grid_sizer.add(@blank_txt,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
143
|
+
@grid_sizer.add(@blank_txt,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
144
|
+
@grid_sizer.add(@blank_txt,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
145
|
+
@grid_sizer.add(@blank_txt,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
146
|
+
@grid_sizer.add(@total_txt,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
147
|
+
#save button
|
148
|
+
@grid_sizer.add(@blank_txt,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
149
|
+
@grid_sizer.add(@blank_txt,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
150
|
+
@grid_sizer.add(@blank_txt,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
151
|
+
@grid_sizer.add(@blank_txt,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
152
|
+
@grid_sizer.add(@load_btn,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
153
|
+
@grid_sizer.add(@save_btn,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
154
|
+
|
155
|
+
#Event Handling
|
156
|
+
evt_spinctrl(@str_spinctrl.get_id()) { |event| str_spinctrl_event(event)}
|
157
|
+
evt_spinctrl(@dex_spinctrl.get_id()) { |event| dex_spinctrl_event(event)}
|
158
|
+
evt_spinctrl(@con_spinctrl.get_id()) { |event| con_spinctrl_event(event)}
|
159
|
+
evt_spinctrl(@int_spinctrl.get_id()) { |event| int_spinctrl_event(event)}
|
160
|
+
evt_spinctrl(@wis_spinctrl.get_id()) { |event| wis_spinctrl_event(event)}
|
161
|
+
evt_spinctrl(@cha_spinctrl.get_id()) { |event| cha_spinctrl_event(event)}
|
162
|
+
evt_choice(@race_choice.get_id()) { |event| race_choice_event(event)}
|
163
|
+
evt_choice(@ability_choice.get_id()) { |event| ability_choice_event(event)}
|
164
|
+
evt_text(@name_edit.get_id()) { |event| name_edit_event(event)}
|
165
|
+
evt_button(@save_btn.get_id()) { |event| save_button_event(event)}
|
166
|
+
evt_button(@load_btn.get_id()) { |event| load_button_event(event)}
|
167
|
+
|
168
|
+
set_sizer(@box_sizer)
|
169
|
+
get_sizer.layout
|
170
|
+
get_sizer.fit(self)
|
171
|
+
|
172
|
+
update_labels
|
173
|
+
|
174
|
+
show
|
175
|
+
end
|
176
|
+
|
177
|
+
def str_spinctrl_event(event)
|
178
|
+
@character.str = @str_spinctrl.get_value
|
179
|
+
update_labels
|
180
|
+
end
|
181
|
+
|
182
|
+
def dex_spinctrl_event(event)
|
183
|
+
@character.dex = @dex_spinctrl.get_value
|
184
|
+
update_labels
|
185
|
+
end
|
186
|
+
|
187
|
+
def con_spinctrl_event(event)
|
188
|
+
@character.con = @con_spinctrl.get_value
|
189
|
+
update_labels
|
190
|
+
end
|
191
|
+
|
192
|
+
def int_spinctrl_event(event)
|
193
|
+
@character.int = @int_spinctrl.get_value
|
194
|
+
update_labels
|
195
|
+
end
|
196
|
+
|
197
|
+
def wis_spinctrl_event(event)
|
198
|
+
@character.wis = @wis_spinctrl.get_value
|
199
|
+
update_labels
|
200
|
+
end
|
201
|
+
|
202
|
+
def cha_spinctrl_event(event)
|
203
|
+
@character.cha = @cha_spinctrl.get_value
|
204
|
+
update_labels
|
205
|
+
end
|
206
|
+
|
207
|
+
def race_choice_event(event)
|
208
|
+
@ability_label.enable(false)
|
209
|
+
@ability_choice.enable(false)
|
210
|
+
race = Race.find(:first, :conditions => { :name => @race_choice.get_string_selection })
|
211
|
+
@character.race = race
|
212
|
+
if race.any then
|
213
|
+
Wx::MessageDialog.new(self, :message=> "Please select an ability score to improve.", :style => Wx::OK).show_modal
|
214
|
+
@ability_label.enable
|
215
|
+
@ability_choice.enable
|
216
|
+
end
|
217
|
+
update_labels
|
218
|
+
end
|
219
|
+
|
220
|
+
def ability_choice_event(event)
|
221
|
+
ability = @ability_choice.get_string_selection
|
222
|
+
@character.set_floating_race_mod(ability)
|
223
|
+
update_labels
|
224
|
+
end
|
225
|
+
|
226
|
+
def name_edit_event(event)
|
227
|
+
@character.name = @name_edit.get_value
|
228
|
+
end
|
229
|
+
|
230
|
+
def save_button_event(event)
|
231
|
+
@character.save
|
232
|
+
end
|
233
|
+
|
234
|
+
def load_button_event(event)
|
235
|
+
csd = Char_select_dialog.new(self)
|
236
|
+
if csd.show_modal == Wx::ID_OK then
|
237
|
+
@character = csd.character
|
238
|
+
@str_spinctrl.value = csd.character.str
|
239
|
+
@dex_spinctrl.value = csd.character.dex
|
240
|
+
@con_spinctrl.value = csd.character.con
|
241
|
+
@int_spinctrl.value = csd.character.int
|
242
|
+
@wis_spinctrl.value = csd.character.wis
|
243
|
+
@cha_spinctrl.value = csd.character.cha
|
244
|
+
#neeed to update name_edit race_choice and ability_choice.....
|
245
|
+
@name_edit.set_value(@character.name)
|
246
|
+
@race_choice.set_string_selection(@character.race.name)
|
247
|
+
if @character.get_floating_race_mod != "" then
|
248
|
+
@ability_choice.set_string_selection(@character.get_floating_race_mod)
|
249
|
+
@ability_choice.enable(true)
|
250
|
+
end
|
251
|
+
update_labels
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
def update_labels
|
256
|
+
if @character.race then
|
257
|
+
@str_rm_txt.set_label(@character.race_mod("str").to_s)
|
258
|
+
@dex_rm_txt.set_label(@character.race_mod("dex").to_s)
|
259
|
+
@con_rm_txt.set_label(@character.race_mod("con").to_s)
|
260
|
+
@int_rm_txt.set_label(@character.race_mod("int").to_s)
|
261
|
+
@wis_rm_txt.set_label(@character.race_mod("wis").to_s)
|
262
|
+
@cha_rm_txt.set_label(@character.race_mod("cha").to_s)
|
263
|
+
end
|
264
|
+
@str_to_txt.set_label(@character.stat("str").to_s)
|
265
|
+
@dex_to_txt.set_label(@character.stat("dex").to_s)
|
266
|
+
@con_to_txt.set_label(@character.stat("con").to_s)
|
267
|
+
@int_to_txt.set_label(@character.stat("int").to_s)
|
268
|
+
@wis_to_txt.set_label(@character.stat("wis").to_s)
|
269
|
+
@cha_to_txt.set_label(@character.stat("cha").to_s)
|
270
|
+
@str_am_txt.set_label(@character.mod("str").to_s)
|
271
|
+
@dex_am_txt.set_label(@character.mod("dex").to_s)
|
272
|
+
@con_am_txt.set_label(@character.mod("con").to_s)
|
273
|
+
@int_am_txt.set_label(@character.mod("int").to_s)
|
274
|
+
@wis_am_txt.set_label(@character.mod("wis").to_s)
|
275
|
+
@cha_am_txt.set_label(@character.mod("cha").to_s)
|
276
|
+
@str_po_txt.set_label(@character.points("str").to_s)
|
277
|
+
@dex_po_txt.set_label(@character.points("dex").to_s)
|
278
|
+
@con_po_txt.set_label(@character.points("con").to_s)
|
279
|
+
@int_po_txt.set_label(@character.points("int").to_s)
|
280
|
+
@wis_po_txt.set_label(@character.points("wis").to_s)
|
281
|
+
@cha_po_txt.set_label(@character.points("cha").to_s)
|
282
|
+
@total_txt.set_label(@character.total_points.to_s)
|
283
|
+
end
|
284
|
+
|
285
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
class Char_select_dialog < Wx::Dialog
|
2
|
+
attr_reader :character
|
3
|
+
def initialize(parent, title = "iSelect a Character to Load")
|
4
|
+
super(parent, Wx::ID_ANY, title)
|
5
|
+
@panel = Wx::Panel.new(self)
|
6
|
+
# Sizers
|
7
|
+
@box_sizer = Wx::BoxSizer.new(Wx::VERTICAL)
|
8
|
+
|
9
|
+
@labels = ["Name","Str", "Dex", "Con", "Int", "Wis", "Cha"]
|
10
|
+
@grid = Wx::Grid.new(self)
|
11
|
+
@grid.create_grid(0, @labels.length)
|
12
|
+
@labels.each do |lab|
|
13
|
+
@grid.set_col_label_value(@labels.index(lab), lab)
|
14
|
+
end
|
15
|
+
@grid.enable_editing(false)
|
16
|
+
@grid.set_selection_mode(Wx::Grid::GridSelectRows)
|
17
|
+
|
18
|
+
@characters = Character.find(:all)
|
19
|
+
|
20
|
+
@characters.each do |char|
|
21
|
+
@grid.insert_rows
|
22
|
+
@grid.set_cell_value(0,0,char.name)
|
23
|
+
@grid.set_cell_value(0,1,char.stat(:str).to_s)
|
24
|
+
@grid.set_cell_value(0,2,char.stat(:dex).to_s)
|
25
|
+
@grid.set_cell_value(0,3,char.stat(:con).to_s)
|
26
|
+
@grid.set_cell_value(0,4,char.stat(:int).to_s)
|
27
|
+
@grid.set_cell_value(0,5,char.stat(:wis).to_s)
|
28
|
+
@grid.set_cell_value(0,6,char.stat(:cha).to_s)
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
@grid.auto_size_columns
|
33
|
+
|
34
|
+
# load Button
|
35
|
+
@load_btn = Wx::Button.new(self,:label=>'Load')
|
36
|
+
|
37
|
+
#Add everythig into the sizer
|
38
|
+
@box_sizer.add(@grid,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
39
|
+
@box_sizer.add(@load_btn,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
40
|
+
|
41
|
+
#Event Handling
|
42
|
+
evt_button(@load_btn.get_id()) { |event| load_button_event(event)}
|
43
|
+
|
44
|
+
set_sizer(@box_sizer)
|
45
|
+
get_sizer.layout
|
46
|
+
get_sizer.fit(self)
|
47
|
+
|
48
|
+
show
|
49
|
+
end
|
50
|
+
|
51
|
+
def load_button_event(event)
|
52
|
+
if @grid.get_selected_rows.size != 1 then
|
53
|
+
Wx::MessageDialog.new(self,"Only Select 1 Row!", "Warning", Wx::OK).show_modal
|
54
|
+
else
|
55
|
+
@character = Character.find_by_name(@grid.get_cell_value(@grid.get_selected_rows[0],0))
|
56
|
+
puts @character.name
|
57
|
+
self.end_modal(Wx::ID_OK)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
class DM_screen_frame < Wx::Frame
|
2
|
+
def initialize(characters)
|
3
|
+
cont = DmScreenController.new
|
4
|
+
@version = cont.current_version_svn
|
5
|
+
@characters = characters
|
6
|
+
super(nil, :title => "Select a Character to Load", :size => [800,600])
|
7
|
+
@panel = Wx::Panel.new(self)
|
8
|
+
create_status_bar
|
9
|
+
create_tool_bar
|
10
|
+
|
11
|
+
self.set_status_text("Current SCM Version: #{@version}")
|
12
|
+
|
13
|
+
menu_bar = Wx::MenuBar.new
|
14
|
+
file_menu = Wx::Menu.new
|
15
|
+
file_menu.append_separator
|
16
|
+
file_menu.append(Wx::ID_EXIT, 'E&xit', 'Exit')
|
17
|
+
menu_bar.append(file_menu, "&File")
|
18
|
+
|
19
|
+
self.menu_bar = menu_bar
|
20
|
+
# Sizers
|
21
|
+
@box_sizer = Wx::BoxSizer.new(Wx::VERTICAL)
|
22
|
+
|
23
|
+
@labels = ["Name","Weapon", "Attack Bonus", "Damage", "Armour", "AC", "Touch", "FF", "HP", "Init Bonus"]
|
24
|
+
@grid = Wx::Grid.new(self)
|
25
|
+
@grid.create_grid(0, @labels.length)
|
26
|
+
@labels.each do |lab|
|
27
|
+
@grid.set_col_label_value(@labels.index(lab), lab)
|
28
|
+
end
|
29
|
+
|
30
|
+
@characters.each do |char|
|
31
|
+
@grid.insert_rows
|
32
|
+
@grid.set_cell_value(0,0,char.name)
|
33
|
+
@grid.set_cell_value(0,1,char.weapon.name)
|
34
|
+
@grid.set_cell_value(0,2,char.attack_mod.to_s)
|
35
|
+
@grid.set_cell_value(0,3,char.weapon.damage.to_s)
|
36
|
+
@grid.set_cell_value(0,4,char.armour.name)
|
37
|
+
@grid.set_cell_value(0,5,char.ac.to_s)
|
38
|
+
@grid.set_cell_value(0,6,char.touch.to_s)
|
39
|
+
@grid.set_cell_value(0,7,char.ff.to_s)
|
40
|
+
@grid.set_cell_value(0,8,char.hp.to_s)
|
41
|
+
@grid.set_cell_value(0,9,char.init.to_s)
|
42
|
+
end
|
43
|
+
|
44
|
+
@grid.auto_size_columns
|
45
|
+
@grid.enable_editing(false)
|
46
|
+
@grid.set_selection_mode(Wx::Grid::GridSelectRows)
|
47
|
+
|
48
|
+
#Add everythig into the sizer
|
49
|
+
@box_sizer.add(@grid,0,Wx::ALIGN_CENTER|Wx::ALL,5)
|
50
|
+
|
51
|
+
#Event Handling
|
52
|
+
evt_menu(Wx::ID_EXIT, :on_exit)
|
53
|
+
|
54
|
+
set_sizer(@box_sizer)
|
55
|
+
get_sizer.layout
|
56
|
+
get_sizer.fit(self)
|
57
|
+
|
58
|
+
show
|
59
|
+
end
|
60
|
+
|
61
|
+
def on_exit
|
62
|
+
close
|
63
|
+
end
|
64
|
+
end
|