module OS
module TCG
class Attack
def initialize(user, target)
@user = user
@target = target
main
end
def main
if @user.position == 0 # Attack Position
if @target.position == 0 # Attack Position
if @user.attack > @target.attack
if !usable_effects?(@target, "AtDeath")
return true
elsif usable_effects?(@target, "AtDeath")
e = get_usable_effects(@target, "AtDeath")
return e
end
elsif @user.attack < @target.attack
if !usable_effects?(@user, "AtDeath")
return false
elsif usable_effects?(@user, "AtDeath")
e = get_usable_effects(@user, "AtDeath")
return e
end
end
elsif @target.position == 1 # Defence Position
if @user.attack > @target.defence
if !usable_effects?(@target, "AtDeath")
return true
elsif usable_effects?(@target, "AtDeath")
e = get_usable_effects(@target, "AtDeath")
return e
end
elsif @user.attack < @target.defence
if !usable_effects?(@user, "AtDeath")
return false
elsif usable_effects?(@user, "AtDeath")
e = get_usable_effects(@user, "AtDeath")
return e
end
end
end
elsif @user.position == 1 # Defence Position
return nil
end
end
def usable_affects?(who, what)
ret = []
if what == "AtDeath"
for i in 0..who.effects.keys.size - 1
if who.effects.keys[i] == "AtDeath"
ret.push(i)
end
end
end
return true if ret.size > 0
return false
end
def get_usable_effects?(who, what)
ret = []
if what == "AtDeath"
for i in 0..who.effects.keys.size - 1
if who.effects.keys[i] == "AtDeath"
ret.push(i)
end
end
end
return ret if ret.size > 0
return nil
end
end
end
end
module OS
module TCG
#=Data======================================================================
# Data
MaxHand = 7
MaxDeck = 120
MinHand = 1 # If greater than 0, duelist will draw until they have this many
# cards if their Hand is under this value.
MaxLife = 10000
StartLife = 5000
MinLife = 0 # If Life reaches this, the duelist fails.
FieldWidth = 5
FieldHieght = 2
#=ID Custom Tags============================================================
# Commands:
Atk = 0 # Attack Opponent
Dfn = 1 # Block Attack
Set = 3 # Set Card on Field (Face Down)
Play = 4 # Set Card on Field (Face Up)
Tap = 5 # Tap a card on the field
Draw = 6 # Draw a card from the Deck
ResG = 7 # Restore a card from the Grave to the Field
Rem = 8 # Remove a card from the Duel entirely
ResR = 9 # Restore a card from Removed to the Field
TapO = 10 # Tap an Opponent's card on the Field
Grav = 11 # Send a card to the Grave
ToHn = 12 # Send a card to its owner's hand
ToDk = 13 # Send a card to its owner's deck
# Targets:
MonS = 0 # User's Monster
MonO = 1 # Opponent's Monster
SplS = 2 # User's Spell
SplO = 3 # Opponent's Spell
ItmS = 4 # User's Item
ItmO = 5 # Opponent's Item
UsHn = 6 # User's Hand
OpHn = 7 # Opponent's Hand
RndHnS = 8 # Random Card from User's Hand
RndHnO = 9 # Random Card from Opponent's Hand
UsDk = 10 # User's Deck
OpDk = 11 # Opponent's Deck
RndDkS = 12 # Random Card from User's Deck
RndHnO = 13 # Random Card from Opponent's Deck
RndMnS = 14 # Random Monster from the User's Field
RndMnO = 15 # Random Monster from the Opponent's Field
RndSpS = 16 # Random Spell from the User's Field
RndSpO = 17 # Random Spell from the Opponent's Field
RndItS = 18 # Random Item from the User's Field
RndItO = 19 # Random Item from the Opponent's Field
# Target Attributes:
# Atk and Dfn will work here as well!
# Status:
NoDuel = 0 # All cards not in a duel have this stat! (slot 0)
InHand = 1 # Card is in a Hand (slot 1)
InDeck = 2 # Card is in a Deck (slot 1)
OnField = 3 # Card is on the Field (slot 1)
Removed = 4 # Removed from play (slot 1)
Altered = 5 # Atk, Dfn, and/or Effects have been altered (slot 2)
InGrave = 6 # Card is in a Grave (slot 1)
AtDeath = 7 # Card has just died...
#=Label Custom Tags=========================================================
# Card Types:
Monster = "Creature"
Spell = "Spell"
Item = "Equipment"
# Elements:
Fire = "Pyro"
Water = "Aqua"
Stone = "Terra"
Plant = "Gaia"
Soul = "Spirit"
Undead = "Cursed"
# Attributes:
Attack = "Atk Power"
Defend = "Dfn Power"
end
end
=begin
There are two types of Custom Tags; ID and Label.
*ID Tags are used in Card and Command declarations. Each ID Custom Tag
equals an integer.
*Label Tags are used in Menus, Descriptions, etc. These are just common
names for things, as well as directories for graphics.
A description of each Custom Tag and its use can be found in the Manual.
When you see the Status CTs, you might notice the (slot #) at the end
of each description. This is to show where in the Array this data will stay.
I did this so you could understand that some States can't occur at the same time,
so they share a slot. If one state has the slot, an other state can't. If the slot
is given a new state, the first one will erase.
=end
module OS
module TCG
class Activate
def initialize(card)
$spriteset = Spriteset_Map.new
@card = card
ef_keys = @card.effects.keys
ef_vals = @card.effects.values
@menu = []
for i in 0..ef_keys.size - 1
@menu.push(ef_keys[i])
@id_m.push(ef_vals[i])
end
end
def main
@activate = Window_Command.new(160, @menu)
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
$spriteset.dispose
@activate.dispose
end
def update
$spriteset.update
@activate.update
if Input.trigger?(Input::B)
$scene = Scene_Map.new
end
if Input.trigger?(Input::C)
for i in 0..@menu.size - 1
if @activate.index == @menu[i]
activate_effect(i)
end
end
end
end
def activate_effect(effect)
if @menu[effect] == "Atk"
if @id_m[effect][0] == "MonS"
out = ["Atk", "MonS", @id_m[effect][1]]
elsif @id_m[effect][0] == "MonO"
out = ["Atk", "MonO", @id_m[effect][1]]
end
end
$game_system.activate_effect = out # Check in a Call Script Command
return
end
end
end
end
module OS
module TCG
class Card
def initialize(name, type = 0, s1 = 100, s2 = 100, s3 = [])
#if type == 0 Monster s1 = Atk s2 = Dfn s3 = effects
#if type == 1 Item s1 = target_card s2 = target_attribute s3 = alter_by/how
#if type == 2 Spell s1 = target_card s2 = target_attribute s3 = alter_by/how
# The difference is Spells go away after use. Items stay until destroyed.
@name = name
@type = type if type == 0 || type == 1 || type == 2
if @type == 0
@atk = s1
@dfn = s2
@effects = s3
else
@target = s1
@attribute = s2
@alterate = s3
end
end
def atk
return @atk if @type == 0
return nil
end
def dfn
return @dfn if @type == 0
return nil
end
def effects
return @effects if @type == 0
return nil
end
def target
return @target if @type != 0
return nil
end
def attribute
return @attribute if @type != 0
return nil
end
def alterate
return @alterate if @type != 0
return nil
end
end
end
end
module OS
module TCG
class Player
def initialize(name, deck, library = nil)
@name = name
@library = library
@deck = deck
@wins = 0
@losses = 0
end
def wins?
return @wins
end
def losses?
return @losses
end
def total?
return @wins + @losses
end
def name
return @name
end
def deck
return @deck
end
def library
return @library
end
end
end
end
module OS
module TCG
class Lib
# Here you will create the Effects
DrawCards = "DrawCards"
# Here you will create the Cards
Cards = {"draw3" => Card.new("Draw X3", 2, "UserDeck", DrawCards, 3)}
# Here you will create the Player's Library and Deck
PlayerLibrary = [Cards["draw3"]]
PlayerStarterDeck = [Cards["draw3"]]
# Here you will create Enemy Decks and Libraries
Enemy1Deck = [Cards["draw3"]]
Enemy2Deck = [Cards["draw3"]]
# And here will be the players
Players = {"Protagonist" => ["OScriptor", PlayerStartDeck, PlayerLibrary], "Antagonist" => ["OverflowS", Enemy1Deck], "Antagonist" => ["OceanS", Enemy2Deck]}
# Methods for creating the Players
def setup_players
keys = Players.keys
vals = Players.values
for i in 0..keys.size - 1
if keys[i] == "Protagonist"
$tcg_player = Player.new(vals[i][0], vals[i][1], vals[i][2])
elsif keys[i] == "Antagonist"
$tcg_badies.push(Player.new(vals[i][0], vals[i][1]))
end
end
end
end
end
end
class Scene_Title
alias os_cng command_new_game
def command_new_game
$tcg_player = nil
$tcg_badies = []
os_cng
end
end