Skip to content

Commit

Permalink
Merge pull request #226 from bcdice/remove-irc-2
Browse files Browse the repository at this point in the history
IRC関連の処理、設定を削除する
  • Loading branch information
ysakasin authored Jul 1, 2020
2 parents e4b26a0 + ffb57d3 commit 497f911
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 196 deletions.
97 changes: 0 additions & 97 deletions src/ArgsAnalizer.rb

This file was deleted.

35 changes: 19 additions & 16 deletions src/CardTrader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
$ircNickRegExp = '[A-Za-z\d\-\[\]\\\'^{}_]+'

class CardTrader
OK_RESULT = '_OK_'.freeze
NG_RESULT = '_NG_'.freeze

# カード置き場数。0なら無し。
# @return [Integer]
attr_accessor :card_place
Expand Down Expand Up @@ -401,7 +404,7 @@ def pickupCardByCards(cards)

cards.each do |card|
string = pickupOneCard(card)
if string == $okResult
if string == OK_RESULT
okCount += 1
else
ngCardList << string
Expand All @@ -424,7 +427,7 @@ def pickupOneCard(card)
if isDelete
@deal_cards[destination] ||= []
@deal_cards[destination] << targetCard
return $okResult
return OK_RESULT
else
return targetCard; # 無かったカードを返す
end
Expand Down Expand Up @@ -467,7 +470,7 @@ def backCardByCommandSetAndPlace(commandset, place)

cards.each do |card|
string = backOneCard(card, destination, place)
if string == $okResult
if string == OK_RESULT
okCount += 1
else
ngCards << string
Expand All @@ -487,7 +490,7 @@ def backOneCard(targetCard, destination, place)

if @card_place > 0 # 場があるときのみ処理
string = transferOneCard(targetCard, "#{place}#{destination}", destination); # 場から手札への移動
return $okResult if string == $okResult
return OK_RESULT if string == OK_RESULT
end

@deal_cards['card_played'] ||= []
Expand All @@ -496,7 +499,7 @@ def backOneCard(targetCard, destination, place)

if isDelete
@deal_cards[destination] << targetCard
return $okResult
return OK_RESULT
end

return "${targetCard}"; # 戻せるカードが無かったらNGのカードを返す
Expand Down Expand Up @@ -628,7 +631,7 @@ def playCardByCardAndPlaceNo(card, place)
result = playOneCard(card, place)
debug("playOneCard result", result)

if result == $okResult
if result == OK_RESULT
okList << card
else
ngList << result
Expand All @@ -651,7 +654,7 @@ def playOneCard(card, place)
result = discardOneCard(card, place, destination); # 場を使わないときは捨て札扱い
end

if result == $okResult
if result == OK_RESULT
return result
else
return card
Expand Down Expand Up @@ -699,7 +702,7 @@ def discardCardsByCardsAndPlace(cards, place, destination)
cards.each do |card|
result = discardOneCard(card, place, destination)

if result == $okResult
if result == OK_RESULT
okList << card
else
ngList << result
Expand Down Expand Up @@ -737,7 +740,7 @@ def discardOneCard(card, place, destination)
@deal_cards['card_played'] += this_cards
debug("@deal_cards", @deal_cards)

return $okResult
return OK_RESULT
else
return card; # 指定のカードが無いので、無いカードを返す
end
Expand Down Expand Up @@ -847,9 +850,9 @@ def transferCardsByCards(cards, destination, nick_e)
debug('transferOneCard result', result)

case result
when $ngResult
when NG_RESULT
return -1, ['渡す相手が登録されていません']
when $okResult
when OK_RESULT
okCount += 1
else
ngCardList << result
Expand Down Expand Up @@ -903,13 +906,13 @@ def transferOneCard(card, from, toSend)
# debug('相手は未登録済み')
isSuccess = transferTargetCardToNewMember(toSend, thisCard)
debug('isSuccess', isSuccess)
return $ngResult unless isSuccess
return NG_RESULT unless isSuccess
end

@deal_cards[from] = restCards
debug("transferOneCard @deal_cards", @deal_cards)

return $okResult
return OK_RESULT
end

def ejectOneCardRandomFromCards(cards)
Expand Down Expand Up @@ -1043,9 +1046,9 @@ def getSendCardToTargetNickPlaceByCards(cards, destination, toSend)
result = transferOneCard(card, destination, toSend)

case result
when $ngResult
when NG_RESULT
return -1, '渡す相手が登録されていません'
when $okResult
when OK_RESULT
okCardList << card
else
ngCardList << result
Expand Down Expand Up @@ -1145,7 +1148,7 @@ def tapOneCardByCardAndPlace(card, place, isUntap)

@nick_e = nick_e_original

if result == $okResult
if result == OK_RESULT
return card, nil
else
return nil, card
Expand Down
2 changes: 0 additions & 2 deletions src/TableFileData.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*-

require 'kconv'
require 'fileutils'
require 'configBcDice.rb'

# extratables ディレクトリに置かれたテーブル定義ファイルを読み込む。
# 詳細はREADME.txtの「7.オリジナルの表追加」を参照。
Expand Down
25 changes: 2 additions & 23 deletions src/bcdiceCore.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,8 @@
require 'log'
require 'configBcDice.rb'
require 'CountHolder.rb'
require 'kconv'
require 'utils/ArithmeticEvaluator.rb'

def decode(code, str)
return str.kconv(code)
end

def encode(code, str)
return Kconv.kconv(str, code)
end

# WindowsでかつRuby 1.9未満の環境であるかどうかを示す
# 端末にShift_JISで出力する必要性の判定に用いる
$RUBY18_WIN = RUBY_VERSION < '1.9' &&
Expand Down Expand Up @@ -89,7 +80,6 @@ def initialize(parent, cardTrader, diceBot, counterInfos, tableFileData)
@tnick = ""
@rands = nil
@isKeepSecretDice = true
@isIrcMode = true

@collect_rand_results = false
@rand_results = []
Expand Down Expand Up @@ -120,6 +110,7 @@ def readExtraCard(cardFileName)
@cardTrader.readExtraCard(cardFileName)
end

# @todo ircClient経由でなく直接メッセージを返すようにする
def setIrcClient(client)
@ircClient = client
end
Expand Down Expand Up @@ -318,7 +309,6 @@ def printPlot
else
debug("message", message)
sendMessage(@channel, message)
sleepForIrc 1
end
end
end
Expand All @@ -345,7 +335,6 @@ def printSecretRoll
next if diceResult.empty?

sendMessage(@channel, diceResult)
sleepForIrc 1
end
end

Expand Down Expand Up @@ -1128,7 +1117,7 @@ def broadmsg(output, nick)
end

if nick == @nick_e
sendMessageToOnlySender(output) # encode($ircCode, output))
sendMessageToOnlySender(output)
else
sendMessage(nick, output)
end
Expand Down Expand Up @@ -1233,14 +1222,4 @@ def setGameByTitle(gameTitle)

return message
end

def setIrcMode(mode)
@isIrcMode = mode
end

def sleepForIrc(second)
if @isIrcMode
sleep(second)
end
end
end
1 change: 0 additions & 1 deletion src/cgiDiceBot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ def executeDiceBot(message, gameType, dir = nil, prefix = '', isNeedResult = fal
bcdice.setTest(@isTest)
bcdice.setCollectRandResult(isNeedResult)
bcdice.setDir(dir, prefix)
bcdice.setIrcMode(false)

if bcdice.getGameType != gameType
bcdice.setGameByTitle(gameType)
Expand Down
17 changes: 2 additions & 15 deletions src/configBcDice.rb
Original file line number Diff line number Diff line change
@@ -1,29 +1,16 @@
# -*- coding: utf-8 -*-

require 'kconv'
require 'configBcDiceForSystem.rb'

$isDebug = false

$bcDiceVersion = "2.06.01"

# @deprecated IRCボット機能の削除に伴い廃止予定。
$SEND_STR_MAX = 405; # 最大送信文字数(本来は500byte上限)
$isRollVoidDiceAtAnyRecive = true; # 発言の度に空ダイスを振るか?

$DICE_MAXCNT = 200; # ダイスが振れる最大個数
$DICE_MAXNUM = 1000; # ダイスの最大面数
$ircCode = Kconv::UTF8; # IRCサーバとの通信に使うコードをRuby::Kconv値で指定
$isHandSort = true; # 手札をソートする必要があるか?
$OPEN_DICE = 'Open Dice!'; # シークレットダイスの出目表示コマンド
$OPEN_PLOT = 'Open Plot!'; # プロットの表示コマンド
$ADD_PLOT = 'PLOT'; # プロットの入力コマンド
$READY_CMD = '#HERE'; # 自分の居るチャンネルの宣言コマンド

# $server = "localhost"; # サーバー
$server = "irc.trpg.net"; # サーバー
$port = 6667; # ポート番号
$defaultLoginChannelsText = "#Dice_Test"; # ボットが最初に参加するチャンネル名
$nick = "bcDICE"
$userName = "v" + $bcDiceVersion # ユーザー名
$ircName = "rubydice"; # IRCネーム
$defaultGameType = "" # デフォルトゲームタイプ
$extraCardFileName = "" # 拡張カードファイル名
7 changes: 0 additions & 7 deletions src/configBcDiceForSystem.rb

This file was deleted.

1 change: 0 additions & 1 deletion src/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
libPaths = [
"#{rootDir}/test",
rootDir,
"#{rootDir}/irc"
]
libPaths.each do |libPath|
$:.push(libPath)
Expand Down
Loading

0 comments on commit 497f911

Please sign in to comment.