03-13-2021, 04:36 AM
Recently I've started developing this scriptlet that should allow me to begin a simple card game. So far it only displays few cards on screen. I haven't added any mechanics to be honest. Even so every card features an ID, a name and two stats, namely attack and defense. Nope, none of these are being displayed right now.
The Scriptlet So Far
The Scriptlet So Far
Code:
# * Karta XP - Alpha Stage
# Scripter : Kyonides Arkanthes
# 2021-03-12
# * Script Calls * #
# $game_party.add_kard(Number)
# It won't add a card to your deck if:
# - Your deck reached the CARD_MAX limit
# - You've got CARD_TYPE_MAX cards of the same kind
# $game_party.enough_kards?
# $game_party.kards_max = Number
# $game_party.kards_max += Number
# $game_party.kards_max -= Number
module Karta
BASE_CARD = 'card base.jpg'
CARD_MIN = 3
CARD_MAX = 20
CARD_TYPE_MAX = 3
NPC_CARD_X = [200, -200]
NPC_CARD_Y = [40]
PLAYER_CARD_X = [200, -200]
PLAYER_CARD_Y = [320]
CARD_NAMES = []
CARD_FILENAMES = [BASE_CARD, BASE_CARD]
end
class Array
def count(n)
group = select{|m| m == n }
group.size
end
end
module RPG::Cache
def self.kard(kid)
self.load_bitmap('Graphics/Kards/' + Karta::CARD_FILENAMES[kid])
end
end
class Kard
attr_reader :id, :attack, :defense
def initialize(cid=0)
@id = cid
@attack = 0
@defense = 0
end
def <=>(other) other.id <=> @id end
def name() Karta::CARD_NAMES[@id] || '?' end
end
class Game_Party
alias :kyon_karta_gm_pty_init :initialize
def initialize
kyon_karta_gm_pty_init
@kards = []
@kards_max = 0
end
def add_kard(n)
return nil if Karta::CARD_MAX + @kards_max == @kards.size
temp_kard = Kard.new(n)
return false if Karta::CARD_TYPE_MAX == @kards.count(temp_kard)
@kards << temp_kard
end
def enough_kards?() Karta::CARD_MIN <= @kards.size end
attr_reader :kards
attr_accessor :kards_max
end
class KardSprite < RPG::Sprite
def initialize(cid=nil)
super(nil)
return unless cid
@id = cid
self.bitmap = RPG::Cache.kard(Karta::BASE_CARD)
end
end
class KartaScene
include Karta
def make_npc_cards
@npc_card_data = [1,2,3]
card_max = @npc_card_data.size
card_max.times do |n|
n = @npc_card_data[n]
@npc_cards << card = KardSprite.new(n)
card.x = NPC_CARD_X[0]
card.y = NPC_CARD_Y[0]
end
end
def make_player_cards
@player_card_data = $game_party.kards.dup
card_max = @player_card_data.size
card_max.times do |n|
n = @player_card_data[n]
@player_cards << card = KardSprite.new(n)
card.x = PLAYER_CARD_X[0]
card.y = PLAYER_CARD_Y[0]
end
end
def main
@npc_cards = []
@player_cards = []
make_npc_cards
make_player_cards
Graphics.transition
loop do
Graphics.update
Input.update
update
break if @exit
end
Graphics.freeze
dispose
end
def dispose
@player_cards.each{|c| c.dispose }
@npc_cards.each{|c| c.dispose }
end
def update
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
return @exit = true
end
end
end
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9
Maranatha!
The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.
My Original Stories (available in English and Spanish)
List of Compiled Binary Executables I have published...
HiddenChest & Roole
Give me a free copy of your completed game if you include at least 3 of my scripts!
Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE
Maranatha!
The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.
My Original Stories (available in English and Spanish)
List of Compiled Binary Executables I have published...
HiddenChest & Roole
Give me a free copy of your completed game if you include at least 3 of my scripts!
Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE