Commit acef34a4 authored by 神楽坂玲奈's avatar 神楽坂玲奈

房内聊天

parent d1bdc32e
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
---
name: "沙沙"
field:
cardimage:
- 1
- 2
- 3
- 4
cardtext:
- 5
- 6
- 7
- 8
chat:
- 9
- 10
- 11
- 12
#encoding: UTF-8
class Action
@@id = 0
attr_reader :from_player, :msg, :id
attr_reader :from_player, :msg
attr_accessor :id
def initialize(from_player=true, msg=nil)
@id = @@id
@from_player = from_player
......
......@@ -145,9 +145,11 @@ class Action
end
end
def self.parse(str)
str =~ /^\[\d+\] (.*)▊▊▊.*?$/m
str =~ /^\[(\d+)\] (.*)▊▊▊.*?$/m
from_player = false
case $1
id = $1.to_i
$chat_window.add from_player, "[#{$1}] #{$2}"
result = case $2
when /^┊(.*)┊$/m
Chat.new from_player, $1
when /^※\[(.*)\]\r\n(.*)\r\n注释$/m
......@@ -206,11 +208,14 @@ class Action
p str, 2
#system("pause")
end
result.id = id
result
end
def escape
inspect
end
def run
$chat_window.add @from_player, escape if @from_player
$iduel.action self if @from_player
end
class FirstToGo
......@@ -371,6 +376,11 @@ class Action
"[#{@id}] ◎→#{pos}#{@card.escape}效果发#{"~" unless (0..10).include? @from_pos}动"
end
end
class Chat
def escape
"[#{@id}] ┊#{@msg}┊"
end
end
end
......
......@@ -15,7 +15,7 @@ class Scene_Duel < Scene
require_relative 'action'
require_relative 'game_card'
require_relative 'game_field'
require_relative 'window_roomchat'
attr_reader :cardinfo_window
attr_reader :action_window
attr_reader :player_field
......@@ -53,7 +53,7 @@ class Scene_Duel < Scene
@cardinfo_window = Window_CardInfo.new(1024-160, 0)
@action_window = Window_Action.new
@chat_window = Window_RoomChat.new(716, 567, 307, 203)
end
def change_phase(phase)
......@@ -151,7 +151,6 @@ class Scene_Duel < Scene
def handle_iduel(event)
case event
when Iduel::Event::Action
p event
event.action.run
@player_field_window.refresh
@opponent_field_window.refresh
......
# To change this template, choose Tools | Templates
# and open the template in the editor.
class Window_RoomChat < Window
require_relative 'widget_scrollbar'
Player_Color = [0,0,0xFF]
Opponent_Color = [0x66,0x66,0]
def initialize(x, y, width, height)
super(x,y,width,height)
@chat_input = Widget_InputBox.new(416,723,586,24){|text|Action::Chat.new(true, text).run}
@font = TTF.open("fonts/WenQuanYi Micro Hei.ttf", 16)
@contents.fill_rect(0,0,@width, @height, 0xFFFFFFFF)
@scroll = Widget_ScrollBar.new(@x+@width-20,@y,@height,0)
@list = []
$chat_window = self
end
def add(player, content)
@list << [player, content]
refresh
end
def refresh
@contents.fill_rect(0,0,@width, @height, 0x66FFFFFF)
@list.last(7).each_with_index do |chat, index|
player, content = chat
@font.draw_blended_utf8(@contents, content, 0, index*WLH, *(player ? Player_Color : Opponent_Color))
end
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment