@@ -29,9 +29,7 @@ def initialize(opts = {})
2929 end
3030
3131 # camel cased name
32- def name
33- @name
34- end
32+ attr_reader :name
3533
3634 def class_name
3735 "CGameController#{ @name } "
@@ -64,7 +62,7 @@ def self.pvp
6462 @@pvp_controller = Controller . new (
6563 path : [ 'base_pvp' ] ,
6664 name : 'pvp' ,
67- filename : 'base_pvp' ,
65+ filename : 'base_pvp'
6866 )
6967 end
7068
@@ -73,7 +71,7 @@ def self.pvp
7371 def self . list
7472 {
7573 pvp : {
76- controller : self . pvp ,
74+ controller : pvp ,
7775 description : 'Basic pvp controller. Top recommendation!'
7876 }
7977 }
@@ -92,6 +90,7 @@ class FileSystemHelper
9290 # @param text [String] text to be written to file
9391 def write ( path , text )
9492 return unless ok_to_overwrite? path
93+
9594 File . write ( path , text )
9695 end
9796
@@ -100,7 +99,7 @@ def ok_to_overwrite?(path)
10099
101100 puts "[!] the following file already exists #{ path } "
102101 puts "[!] do you really want to overwrite it? (y/N)"
103- return true if $stdin. gets . chomp . match? /[Yy](es)?/
102+ return true if $stdin. gets . chomp . match? ( /[Yy](es)?/ )
104103
105104 puts "[!] skipping file ..."
106105 false
@@ -199,7 +198,7 @@ def constructor_body
199198 "m_pStatsTable = \" #{ @controller . name_snake } \" ;" ,
200199 "m_pExtraColumns = nullptr; // new C#{ @controller . name } Columns();" ,
201200 "m_pSqlStats->SetExtraColumns(m_pExtraColumns);" ,
202- "m_pSqlStats->CreateTable(m_pStatsTable);" ,
201+ "m_pSqlStats->CreateTable(m_pStatsTable);"
203202 ] . map { |m | "\t #{ m } " } . join ( "\n " )
204203 end
205204
@@ -209,15 +208,14 @@ def include_guard_open
209208 slug += @controller . name . to_snake . upcase
210209 [
211210 "#ifndef GAME_SERVER_GAMEMODES_#{ slug } _H" ,
212- "#define GAME_SERVER_GAMEMODES_#{ slug } _H" ,
211+ "#define GAME_SERVER_GAMEMODES_#{ slug } _H"
213212 ] . join ( "\n " )
214213 end
215214
216215 def include_guard_close
217216 "#endif"
218217 end
219218
220-
221219 def source_methods
222220 # TODO: the header and source methods should be be kept in sync with some kind of data structure
223221 # that matches methods by name
@@ -230,16 +228,16 @@ def source_methods
230228 "void #{ @controller . class_name } ::OnInit()" ,
231229 empty_method_body ( "void" ) ,
232230 "int #{ @controller . class_name } ::OnCharacterDeath(CCharacter *pVictim, class CPlayer *pKiller, int Weapon)" ,
233- empty_method_body ( "int" ) ,
231+ empty_method_body ( "int" )
234232 ] . join ( "\n " )
235233 end
236234
237235 def empty_method_body ( return_type )
238236 lines = [ "{" ]
239237 case return_type
240- when "void" then nil
241- when "int" then lines << " return 0;"
242- else raise "Unknown return type: #{ return_type } "
238+ when "void" then nil
239+ when "int" then lines << " return 0;"
240+ else raise "Unknown return type: #{ return_type } "
243241 end
244242 lines << "}"
245243 lines << ""
@@ -249,7 +247,7 @@ def empty_method_body(return_type)
249247 def header_methods
250248 [
251249 "void OnInit() override;" ,
252- "int OnCharacterDeath(class CCharacter *pVictim, CPlayer *pKiller, int Weapon) override;" ,
250+ "int OnCharacterDeath(class CCharacter *pVictim, CPlayer *pKiller, int Weapon) override;"
253251 ] . map { |m | "\t #{ m } " } . join ( "\n " )
254252 end
255253end
0 commit comments