差分

DiceAdapterについて追記する
12行目: 12行目:     
https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb
 
https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb
 +
 +
ダイスロールと関係していることがすぐに分かるファイル名だが、実はほとんど独自の表からの情報の読み出しやファイル管理の処理となっている。
    
=== L7-L10:<code>DiceAdapter#initialize</code> ===
 
=== L7-L10:<code>DiceAdapter#initialize</code> ===
64行目: 66行目:     
https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb#L36-L45
 
https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb#L36-L45
 +
 +
独自の表について、ゲームタイプ(ゲームの識別子)および含まれるコマンドの情報を返す。<code>CgiDiceBot#getGameCommandInfos</code> を経由して <code>TableFileData#getGameCommandInfos</code> を呼び出している。
    
<syntaxhighlight lang="ruby">
 
<syntaxhighlight lang="ruby">
75行目: 79行目:     
   return commandInfos
 
   return commandInfos
 +
end
 +
</syntaxhighlight>
 +
 +
=== L47-L63:<code>DiceAdapter#getBotTableInfosFromDir</code> ===
 +
 +
https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb#L47-L63
 +
 +
独自の表についての情報を取得する。<code>getGameCommandInfos</code> と似ているが、こちらの方が返される情報が詳しい?
 +
 +
<syntaxhighlight lang="ruby">
 +
def getBotTableInfosFromDir
 +
  @logger.debug(@dir, 'getBotTableInfosFromDir dir')
 +
 +
  require 'TableFileData'
 +
 +
  isLoadCommonTable = false
 +
  tableFileData = TableFileData.new( isLoadCommonTable )
 +
  tableFileData.setDir(@dir, @diceBotTablePrefix)
 +
  tableInfos = tableFileData.getAllTableInfo
 +
 +
  @logger.debug(tableInfos, "getBotTableInfosFromDir tableInfos")
 +
  tableInfos.sort!{|a, b| a["command"].to_i <=> b["command"].to_i}
 +
 +
  @logger.debug(tableInfos, 'getBotTableInfosFromDir result tableInfos')
 +
 +
  return tableInfos
 +
end
 +
</syntaxhighlight>
 +
 +
=== L65-L84:<code>DiceAdapter#addBotTableMain</code> ===
 +
 +
https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb#L65-L84
 +
 +
独自の表のファイルを保存する。
 +
 +
<syntaxhighlight lang="ruby">
 +
def addBotTableMain(params)
 +
  @logger.debug("addBotTableMain Begin")
 +
 +
  DodontoF::Utils.makeDir(@dir)
 +
 +
  require 'TableFileData'
 +
 +
  resultText = 'OK'
 +
  begin
 +
    creator = TableFileCreator.new(@dir, @diceBotTablePrefix, params)
 +
    creator.execute
 +
  rescue Exception => e
 +
    @logger.exception(e)
 +
    resultText = getLanguageKey( e.to_s )
 +
  end
 +
 +
  @logger.debug(resultText, "addBotTableMain End resultText")
 +
 +
  return resultText
 +
end
 +
</syntaxhighlight>
 +
 +
=== L86-L103:<code>DiceAdapter#changeBotTableMain</code> ===
 +
 +
https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb#L86-L103
 +
 +
独自の表のファイルを更新する。
 +
 +
<syntaxhighlight lang="ruby">
 +
def changeBotTableMain(params)
 +
  @logger.debug("changeBotTableMain Begin")
 +
 +
  require 'TableFileData'
 +
 +
  resultText = 'OK'
 +
  begin
 +
    creator = TableFileEditer.new(@dir, @diceBotTablePrefix, params)
 +
    creator.execute
 +
  rescue Exception => e
 +
    @logger.exception(e)
 +
    resultText = getLanguageKey( e.to_s )
 +
  end
 +
 +
  @logger.debug(resultText, "changeBotTableMain End resultText")
 +
 +
  return resultText
 +
end
 +
</syntaxhighlight>
 +
 +
=== L105-L135:<code>DiceAdapter#removeBotTableMain</code> ===
 +
 +
https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb#L86-L103
 +
 +
独自の表のファイルを削除する。
 +
 +
<syntaxhighlight lang="ruby">
 +
def removeBotTableMain(params)
 +
  @logger.debug("removeBotTableMain Begin")
 +
 +
  command = params["command"]
 +
 +
  require 'TableFileData'
 +
 +
  isLoadCommonTable = false
 +
  tableFileData = TableFileData.new( isLoadCommonTable )
 +
  tableFileData.setDir(@dir, @diceBotTablePrefix)
 +
  tableInfos = tableFileData.getAllTableInfo
 +
 +
  tableInfo = tableInfos.find{|i| i["command"] == command}
 +
  @logger.debug(tableInfo, "tableInfo")
 +
  return if( tableInfo.nil? )
 +
 +
  fileName = tableInfo["fileName"]
 +
  @logger.debug(fileName, "fileName")
 +
  return if( fileName.nil? )
 +
 +
  @logger.debug("isFile exist?")
 +
  return unless( File.exist?(fileName) )
 +
 +
  begin
 +
    File.delete(fileName)
 +
  rescue Exception => e
 +
    @logger.exception(e)
 +
  end
 +
 +
  @logger.debug("removeBotTableMain End")
 
end
 
end
 
</syntaxhighlight>
 
</syntaxhighlight>