05-13-2021, 10:12 AM 
(This post was last modified: 05-13-2021, 10:16 AM by kyonides.
 Edit Reason: added final warning
)
	
	
	
		Yeap, I've come back with another report on the development stage of KLords of XP!  
 
This time I've changed lots of lines of code that you'd rarely use in game and I had to rewrite lots of methods and add a few methods or even a new class like the Spy class!
 Spy class!  
 
So if you don't own that shire or pretend you do that's not a problem, you'd just send a spy to get as much info as possible!
 that's not a problem, you'd just send a spy to get as much info as possible!  
 
That doesn't mean the spy isn't some sort of double agent like
 spy isn't some sort of double agent like  ninjas might be!
 ninjas might be!
 Of course, that's just the button. Its API isn't finished, yet.
 Of course, that's just the button. Its API isn't finished, yet.  
 
	
	
	
 
 This time I've changed lots of lines of code that you'd rarely use in game and I had to rewrite lots of methods and add a few methods or even a new class like the
 Spy class!
 Spy class!  
 So if you don't own that shire or pretend you do
 that's not a problem, you'd just send a spy to get as much info as possible!
 that's not a problem, you'd just send a spy to get as much info as possible!  
 That doesn't mean the
 spy isn't some sort of double agent like
 spy isn't some sort of double agent like  ninjas might be!
 ninjas might be! Of course, that's just the button. Its API isn't finished, yet.
 Of course, that's just the button. Its API isn't finished, yet.  
 Code:
# * KLords of XP - Alpha Release
#   Scripter : Kyonides Arkanthes
#   2021-05-12
=begin
 This is a free adaptation of Lords of the Realm 2 game for RMXP. The goal of
 this script is to partially replicate some of its features.
 The king is dead! The war of succession has just begun!
 This game places you as a feudal lord or knight in charge of a shire or county
 and you are a candidate to become the next king. The game is divided by turns
 corresponding to the annual seasons.
* Reserved Lord ID's
 0 - Independent Shires
 1 - The Player!
# * Script Calls * #
* Open the KLords of XP Scene OR the Player's Name Scene if needed
- Later on it will automatically open the KLords of XP Scene
open_klords_map
* Open the KLords of XP Scene (No Player's Name Setup Needed)
$scene = KLords::MapScene.new
* Set Current Party Leader as Lord (alias the Player) - In Game
$game_party.leader_as_lord
* Select the Next Map of Shires to be ruled by the lords - In Game
$game_system.next_shires_map
* Set a New Season and Year - In Game
$game_system.new_calendar(season, year)
* Retrieve All Lords You Have Configured
$game_system.lords
$game_system.lord(LordID)
$game_system.lord_name(LordID)
$game_system.lord_shires(LordID)
$game_system.lord_allies(LordID)
* Retrieve How Many Crowns (Gold) a given Lord has earned so far
$game_system.lord_crowns(LordID)
$game_system.lord_gain_crowns(LordID)
$game_system.lord_lose_crowns(LordID)
* Retrieve All Shires (Regions) You Have Configured
$game_system.shires
$game_system.shire(ShireID)
$game_system.shire_land_id(ShireID)
$game_system.shire_lord_id(ShireID)
$game_system.shire_change_lord(ShireID, LordID)
=end
module KLords
  # Include an * asterisk at the end of the base filename
  SHIRES_TEMP_BASENAME = "KLords/ShiresMap*"
  SHIRES_DATA_FILENAME = "Data/ShiresMapInfos.rxdata"
  BASIC_DATA_FILENAME = "Data/KLordsXP.rxdata"
  # Initial Player's Options
  # :need_name - true (open name scene) or false
  # :name - "Name" or nil if not using it
  # :no_lord_name - "Name" If the shire has no ruler, pick this label instead
  # :chars - Character Limit
  PLAYER_SETUP = {
    :need_name => true,
    :name => "Gawain",
    :no_lord_name => "Independent",
    :chars => 16
  }
  # Initial Mini Game Date Setup: seasons 1 through 4
  DATE = { :season => 1, :year => 750 }
  TROOP_TYPE_MAX = 8
  # Picture used as some sort of Menu Bar
  RIBBON = "ribbon"
  # List of Icons representing the player and the rest of the nobles
  NOBLE_ICONS = ["",""]
  BUILDING_ICONS = ["keep01","keep03","castle01","castle01"]
  DEFENSE_ICONS = ["keep02", "keep04", "castle02","castle03"]
  ENV_ICONS = ["tree01","tree02","woodstock"]
  # KLords Main Menu BGM
  BGM = ["menu01","menu02"]
  class Texts
    attr_accessor :winter, :spring, :summer, :autumn, :lord, :title
    attr_accessor :crowns, :not_ruler, :autonomous, :send_spy
    attr_accessor :wood, :stone, :gold, :iron, :population, :tax
  end
  LABELS = Texts.new
  LABELS.winter = "Winter"
  LABELS.spring = "Spring"
  LABELS.summer = "Summer"
  LABELS.autumn = "Autumn"
  LABELS.lord = "Current Lord"
  LABELS.title = "Stockpiles"
  LABELS.crowns = "Crowns"
  LABELS.not_ruler = "Sovereign land of"
  LABELS.autonomous = "Self Governed"
  LABELS.send_spy = "Send Spy"
  LABELS.wood = "Wood"
  LABELS.stone = "Stone"
  LABELS.gold = "Gold"
  LABELS.iron = "Iron"
  LABELS.population = "Pop."
  LABELS.tax = "Tax"
  ICONS = {
    :people => "population", :tax => "tax",
    :happy => "heart", :health => "health",
    :cattle => "cattle", :grain => "wheat", :wood => "wood"
  }
  ICONS.default = "" # Do Not Edit This Line!
  # MapID => "Land Backdrop", etc.
  MAPDATA = { 2 => "" }
  MAPDATA.default = ""
  module SpyData
    BASIC_INCOME = 250
    INCOME_INCREASE_STEP = 50
    # SpyID => { :vary => Percent, :quality => Integer }, etc.
    # Integer can be 0+, the higher the better the pay the spy will get
    FEATURES = { 1 => { :vary => 50, :quality => 1 } }
    FEATURES.default = { :vary => 0, :quality => 0 }
    def self.salary(spy_id)
      BASIC_INCOME + FEATURES[spy_id][:quality] * INCOME_INCREASE_STEP
    end
  end
  module FontSetup
  # Font Color is optional, Options: none - white, :black, :gray or some
  # R,G,B or R,G,B,A list of Integers 0..255
    # SECTION = [ "Font Name", Size, Bold, Color ]
    SEASON = ["Blackwood Castle", 20, false, :black]
    SHIRE = ["Blackwood Castle", 30, false, :gray]
    NOT_SAME_LORD = ["Blackwood Castle", 26, false]
    SEND_SPY = ["Blackwood Castle", 25, false]
    SHIRE_LABELS = ["Arial", 20, true, 40, 255, 60]
    SHIRE_STATS = ["Arial", 22, false, 40, 255, 60]
    MAP = ["Arial", 20, true, 0, 255, 60]
    WHICH_LORD = ["Arial", 22, false]
    THIS_LORD = ["Arial", 22, false]
  end
end
class Array
  def to_color
    Color.new(shift, shift || 255, shift || 255, shift || 255)
  end
end
class String
  def scan_int() scan(/\d+/)[0].to_i end
end
class Font
  def self.find_color(sym)
    case sym
    when :black
      Color.new(0, 0, 0, 255)
    when :gray
      Color.new(60, 60, 60, 255)
    else
      Color.new(255, 255, 255)
    end
  end
  def set(ary)
    ary = ary.dup
    self.name = ary.shift
    self.size = ary.shift || 22
    self.bold = ary.shift || false
    return if ary.empty?
    self.color = ary.size == 1 ? Font.find_color(ary.shift) : ary.to_color
  end
end
class Sprite
  def set_xy(nx, ny)
    self.x = nx
    self.y = ny
  end
end
module KLords
  extend self
  attr_accessor :lord, :shire
  module MapData
    @infos = load_data("Data/MapInfos.rxdata")
    @infos[0] = RPG::MapInfo.new
    extend self
    attr_accessor :map_list, :shires_infos
    def map(mid) @infos[mid] end
    def shires_map(mid) @shires_infos[mid] end
    def load_shires_map_infos
      @map_list = load_data(BASIC_DATA_FILENAME)
      @shires_infos = load_data(SHIRES_DATA_FILENAME)
    end
    def create_shire(map_id, lines)
      map = @shires_infos[map_id]
      shire_id = map.shires.size + 1
      shire = Shire.new(shire_id)
      @shires_infos[map_id].shires << shire
      shire.name = lines.shift.sub(/name: /i, "").chomp
      shire.lord_id = lines.shift.scan_int
      shire.size = lines.shift.sub(/size: /i, "").downcase.to_sym
      stats = shire.stats
      stats.population = lines.shift.scan_int
      stats.tax = lines.shift.scan_int
      stats.health = lines.shift.scan_int
      stats.happiness = lines.shift.scan_int
      n, f, c, g = lines.shift.scan(/\d+/).map{|d| d.to_i }
      shire.resources.change_acres_usage(n, f, c, g)
      lines.shift
    end
    def parse_shires(filename)
      lines = File.readlines(filename)
      map_id = filename.scan_int
      emap_id = lines.shift.scan_int
      @map_list << emap_id
      @shires_infos[map_id] = Map.new(map_id, emap_id)
      lines.shift
      shires_max = lines.size / 8
      shires_max.times{ create_shire(map_id, lines) }
    end
    def parse_shires_map_data
      unless $DEBUG
        load_shires_map_infos
        return
      end
      @map_list = [nil]
      @shires_infos = [nil]
      files = Dir[SHIRES_TEMP_BASENAME].sort
      if files.empty?
        dir = SHIRES_TEMP_BASENAME.split("/")[0]
        raise IOError, "No temporal file was found at " + dir + " directory!"
      end
      files.each{|file| parse_shires(file) }
      save_data(@map_list, BASIC_DATA_FILENAME)
      save_data(@shires_infos, SHIRES_DATA_FILENAME)
    end
  end
  class Setup
    def initialize
      @need_name = PLAYER_SETUP[:need_name]
      @temp_name = PLAYER_SETUP[:name]
      @pos = 0
    end
    attr_accessor :need_name, :temp_name, :pos
  end
  
  class Kalender
    def initialize(pos, year)
      self.season = pos
      @year = year
    end
    def next_season() @season = (@season + 1) % 4 end
    def season=(ns) @season = (ns - 1) % 4 end
    def season() @season end
    attr_accessor :year
  end
  class Acre
    def initialize
      @usage = :fallow
      @results = 0
    end
    def fallow?() @usage == :fallow end
    def producing?() @usage == :cattle or @usage == :grain end
    attr_accessor :usage, :results
  end
  class Resources
    def initialize
      @cattle = 0
      @grain = 0
      @wood = 0
      @stone = 0
      @iron = 0
      @gold = 0
      @ale = 0
      @medicines = 0
    end
    def change_acres_usage(n, f, c, g)
      setup_acres(n + f + c + g)
      pos = 0
      n.times do
        @acres[pos].usage = nil
        pos += 1
      end
      f.times do
        @acres[pos].usage = :fallow
        pos += 1
      end
      c.times do
        @acres[pos].usage = :cattle
        pos += 1
      end
      g.times do
        @acres[pos].usage = :grain
        pos += 1
      end
    end
    def setup_acres(total)
      @acres_max = total
      @acres = Array.new(total){ Acre.new }
    end
    def acres_fallow() @acres.select{|a| a.fallow? }.size end
    def acres_used() @acres.select{|a| a.producing? }.size end
    def land_usage(pos) @acres[pos].usage end
    def change_land_usage(pos, mode) @acres[pos].usage = mode end
    attr_accessor :acres, :acres_max, :cattle, :grain, :wood, :stone
    attr_accessor :iron, :gold, :ale, :medicines
  end
  class MapObject
    def initialize(moid) @id = moid end
    attr_accessor :id, :name
  end
  
  class Lord < MapObject
    def initialize(lid)
      super(lid)
      @name = "Unknown"
      @shires = []
      @lands = 0
      @title = "Civil Servant"
      @crowns = 0
      @allies = []
      @armies = []
      @victories = -1
    end
    def add_shire(sid)
      @shires << sid
      @shires = @shires.uniq.sort
    end
    def lose_shire(sid)
      @shires.delete(sid)
    end
    def join_armies(t1, t2)
      @armies[t1].join_army(@armies[t2])
      @armies.delete_at(t2)
      @armies[t1]
    end
    attr_accessor :shires, :lands, :title, :crowns, :allies, :armies, :victories
  end
  class ShireStats
    def initialize
      @tax = 0
      @happiness = 50
      @health = 50
      @population = 10
    end
    attr_accessor :tax, :happiness, :health, :population
  end
  class Shire < MapObject
    def initialize(sid)
      super(sid)
      @name = "Lost Shire"
      @land_id = 0
      @lord_id = 0
      @stats = ShireStats.new
      @resources = Resources.new
      @size = :medium
      @has_spies = false
      @threats = []
    end
    attr_accessor :land_id, :lord_id, :stats, :size, :has_spies
    attr_reader :resources, :threats
  end
  class Army
    def initialize
      @name = ""
      @troops = Array.new(TROOP_TYPE_MAX, 0)
    end
    def join_army(army)
      TROOP_TYPE_MAX.times{|n| @troops[n] += army.troops[n] }
    end
    attr_accessor :name
    attr_reader :troops
  end
  class Map
    def initialize(mid, editor_map_id)
      @id = mid
      @editor_map_id = editor_map_id
      @shires = []
    end
    attr_accessor :shires
    attr_reader :id, :editor_map_id
  end
  class Spy
    include SpyData
    def initialize(spy_id, shire)
      features = FEATURES[spy_id]
      @variance = FEATURES[spy_id][:vary]
      @shire_id = shire
      @wage = SpyData.salary(spy_id)
      @data = Resources.new
      @stats = ShireStats.new
      @armies = []
      @targets = []
    end
    attr_accessor :shire_id, :variance, :wage, :data, :stats, :armies, :targets
  end
# * End of Data Classes #
  class NameEditWindow < Window_NameEdit
    def initialize(actor, max_char)
      super
      self.contents = Bitmap.new(width - 32, height - 32)
      @actor = actor
      name = actor.name
      @max_char = max_char
      name_array = name.split(//)[0...@max_char]
      @name = ""
      name_array.size.times{|i| @name += name_array[i] }
      @default_name = @name
      @index = name_array.size
      refresh
      update_cursor_rect
    end
    def refresh
      self.contents.clear
      name_array = @name.split(//)
      @max_char.times do |i|
        c = name_array[i] || " "
        x = 320 - @max_char * 14 + i * 28
        self.contents.draw_text(x, 32, 28, 32, c, 1)
      end
      #draw_actor_graphic(@actor, 320 - @max_char * 14 - 40, 80)
    end
  end
  class NameScene < Scene_Name
    def main
      @actor = $game_system.lords[1]
      @edit_window = NameEditWindow.new(@actor, PLAYER_SETUP[:chars])
      @input_window = Window_NameInput.new
      Graphics.transition
      loop do
        Graphics.update
        Input.update
        update
        break if $scene != self
      end
      Graphics.freeze
      @edit_window.dispose
      @input_window.dispose
    end
    def check_name
      @edit_window.restore_default
      no_name = @edit_window.name.empty?
      se = no_name ? $data_system.decision_se : $data_system.buzzer_se
      $game_system.se_play(se)
    end
    def update
      @edit_window.update
      @input_window.update
      if Input.repeat?(Input::B)
        return if @edit_window.index == 0
        $game_system.se_play($data_system.cancel_se)
        @edit_window.back
        return
      elsif Input.trigger?(Input::C)
        if @input_window.character == nil
          return check_name if @edit_window.name == ""
          @actor.name = @edit_window.name
          $game_system.se_play($data_system.decision_se)
          return $scene = KLords::MapScene.new
        end
        if @edit_window.index == $game_temp.name_max_char or
           @input_window.character == ""
          return $game_system.se_play($data_system.buzzer_se)
        end
        $game_system.se_play($data_system.decision_se)
        @edit_window.add(@input_window.character)
      end
    end
  end
  class IconLabel
    def initialize(nx, ny, type, w=68)
      @icon = Sprite.new
      @icon.set_xy(nx, ny)
      @icon.bitmap = RPG::Cache.icon(ICONS[type])
      @label = Sprite.new
      @label.set_xy(nx + 28, ny + 2)
      @label.bitmap = Bitmap.new(w, 24)
    end
    def set_text(text)
      b = @label.bitmap
      b.clear
      b.font.set FontSetup::SHIRE_LABELS
      b.draw_text(0, 0, b.width, 24, text, 1)
    end
    def visible=(bool)
      @icon.visible = bool
      @label.visible = bool
    end
    def dispose
      @icon.bitmap.dispose
      @icon.dispose
      @label.bitmap.dispose
      @label.dispose
    end
  end
  def season_name(season)
    case season
    when 0 then LABELS.winter
    when 1 then LABELS.spring
    when 2 then LABELS.summer
    when 3 then LABELS.autumn
    end
  end
  class MapSpriteset < Spriteset_Map
    def initialize
      @viewport1 = Viewport.new(0, 0, 640, 480)
      @viewport2 = Viewport.new(0, 0, 640, 480)
      @viewport2.z = 200
      @tilemap = Tilemap.new(@viewport1)
      @tilemap.tileset = RPG::Cache.tileset($game_map.tileset_name)
      7.times do |i|
        autotile_name = $game_map.autotile_names[i]
        @tilemap.autotiles[i] = RPG::Cache.autotile(autotile_name)
      end
      @tilemap.map_data = $game_map.data
      @tilemap.priorities = $game_map.priorities
      @panorama = Plane.new(@viewport1)
      @panorama.z = -1000
      backdrop = MAPDATA[$game_map.map_id][0]
      #@panorama.bitmap = RPG::Cache.panorama(backdrop, 0)
      @character_sprites = []
      $game_map.events.keys.sort.each do |i|
        sprite = Sprite_Character.new(@viewport1, $game_map.events[i])
        @character_sprites << sprite
      end
      @picture_sprites = []
      for i in 1..50
        sprite = Sprite_Picture.new(@viewport2, $game_screen.pictures[i])
        @picture_sprites << sprite
      end
    end
    def dispose
      @tilemap.tileset.dispose
      7.times{|i| @tilemap.autotiles[i].dispose }
      @tilemap.dispose
      #@panorama.dispose
      @character_sprites.each{|sprite| sprite.dispose }
      @picture_sprites.each{|sprite| sprite.dispose }
      @viewport1.dispose
      @viewport2.dispose
    end
  end
  class Spriteset
    BAR_WIDTH = 200
    def initialize
      @map_id = MapData.map_list[$game_system.map_id]
      @shire = $game_system.last_shire
      @lord = $game_system.lord(@shire.lord_id)
      @baseh = 4 + @shire.lord_id == 1 ? 0 : 48
      @lineh = 28
      @ribbon = Sprite.new
      @ribbon.bitmap = RPG::Cache.picture(RIBBON)
      make_general_data
      make_not_same_lord
      make_stats
      make_send_spy
      refresh_calendar
      refresh_crowns
      refresh_shire_name
      if @shire.lord_id == 1
        @not_lord.visible = false
        refresh_stats
      else
        show_icon_labels(false)
        refresh_not_ruler
        @send_spy.visible = !@shire.has_spies
      end
    end
    def make_general_data
      @calendar = Sprite.new
      @calendar.set_xy(4, 2)
      @calendar.bitmap = Bitmap.new(120, 24)
      @crowns = Sprite.new
      @crowns.set_xy(132, 2)
      @crowns.bitmap = Bitmap.new(BAR_WIDTH, 24)
      @shire_name = Sprite.new
      @shire_name.set_xy(4, 2 + @lineh)
      @shire_name.bitmap = Bitmap.new(BAR_WIDTH, 24)
    end
    def make_not_same_lord
      @not_lord = Sprite.new
      @not_lord.set_xy(4, 64)
      @not_lord.bitmap = Bitmap.new(BAR_WIDTH, 48)
    end
    def make_stats
      @people = IconLabel.new(4, @baseh + @lineh * 2, :people)
      @happy = IconLabel.new(104, @baseh + @lineh * 2, :happy)
      @tax = IconLabel.new(4, @baseh + @lineh * 3, :tax)
      @health = IconLabel.new(104, @baseh + @lineh * 3, :health)
      @cattle = IconLabel.new(4, @baseh + @lineh * 4, :cattle)
      @grain = IconLabel.new(4, @baseh + @lineh * 5, :grain)
      @wood = IconLabel.new(104, @baseh + @lineh * 4, :wood)
      @icon_labels = [@people, @happy, @tax, @health, @cattle, @grain, @wood]
    end
    def make_send_spy
      @send_spy = Sprite.new
      @send_spy.visible = false
      @send_spy.set_xy(20, 148)
      @send_spy.bitmap = b = Bitmap.new(160, 32)
      b.font.set FontSetup::SEND_SPY
      b.fill_rect(b.rect, Font.find_color(:gray))
      b.draw_text(0, 0, b.width, 32, LABELS.send_spy, 1)
      @sprites = [@ribbon, @calendar, @crowns, @shire_name, @send_spy]
    end
    def refresh_calendar
      calendar = $game_system.calendar
      year = calendar.year.to_s
      season = KLords.season_name(calendar.season)
      b = @calendar.bitmap
      b.clear
      yw = b.text_size(year).width
      b.font.set FontSetup::SEASON
      b.draw_text(0, 0, yw, 24, year)
      b.draw_text(yw + 8, 0, b.width - yw - 8, 24, season)
    end
    def refresh_crowns
      gold = @lord.crowns.to_s
      b = @crowns.bitmap
      b.clear
      gw = b.text_size(gold).width
      b.font.set FontSetup::SEASON
      b.draw_text(0, 0, b.width, 24, gold)
      b.draw_text(gw + 4, 0, b.width - gw - 4, 24, LABELS.crowns)
    end
    def refresh_shire_name
      b = @shire_name.bitmap
      b.clear
      b.font.set FontSetup::SHIRE
      b.draw_text(0, 0, b.width, 24, @shire.name, 1)
    end
    def refresh_not_ruler
      b = @not_lord.bitmap
      b.clear
      b.font.set FontSetup::NOT_SAME_LORD
      text = @shire.lord_id == 0 ? LABELS.autonomous : LABELS.not_ruler
      b.draw_text(0, 0, b.width, 24, text, 1)
      @not_lord.visible = true
    end
    def refresh_stats
      stats = @shire.stats
      res = @shire.resources
      @people.set_text(stats.population.to_s)
      @happy.set_text(stats.happiness.to_s + "%")
      @tax.set_text(stats.tax.to_s + "%")
      @health.set_text(stats.health.to_s + "%")
      @cattle.set_text(res.cattle.to_s)
      @grain.set_text(res.grain.to_s)
      @wood.set_text(res.wood.to_s)
    end
  #make_map_name make_which_lord make_lord_name@name@which_lord@lord_name
    def make_map_name
      map = MapData.map(@map_id).name
      @name = Sprite.new
      @name.y = 8
      @name.bitmap = b = Bitmap.new(BAR_WIDTH, 24)
      b.font.set MAP
      b.draw_text(0, 0, b.width, 24, map, 1)
    end
    def make_which_lord
      @which_lord = Sprite.new
      @which_lord.y = 64
      @which_lord.bitmap = b = Bitmap.new(BAR_WIDTH, 24)
      b.font.set WHICH_LORD
      b.draw_text(0, 0, b.width, 24, LABELS.lord)
    end
    def make_lord_name
      @lord_name = Sprite.new
      @lord_name.y = 92
      @lord_name.bitmap = b = Bitmap.new(BAR_WIDTH, 24)
      b.font.set THIS_LORD
      b.draw_text(0, 0, b.width, 24, KLords.lord.name, 1)
    end
    def dispose
      @not_lord.bitmap.dispose
      @not_lord.dispose
      @sprites.each do |s|
        s.bitmap.dispose
        s.dispose
      end
      @icon_labels.each{|s| s.dispose }
      @sprites.clear
      @icon_labels.clear
    end
    def show_icon_labels(bool) @icon_labels.each{|lbl| lbl.visible = bool } end
    attr_reader :shire, :lord
  end
  class MapScene < Scene_Map
    def main
      KLords.lord = $game_system.lord(1)
      map_id = MapData.map_list[$game_system.map_id]
      old_map_id = $game_map.map_id
      different_map = old_map_id != map_id
      $game_map.setup(map_id) if different_map
      Audio.bgm_stop
      path = "Audio/BGM/" + BGM[0]
      Audio.bgm_play(path)
      @open = true
      @tileset = MapSpriteset.new
      @spriteset = Spriteset.new
      Graphics.transition
      while @open
        Graphics.update
        Input.update
        update
      end
      Graphics.freeze
      @spriteset.dispose
      @tileset.dispose
      $game_system.bgm_replay
      $game_map.setup(old_map_id) if different_map
    end
    def update
      if Input.trigger?(Input::B)
        $game_system.se_play($data_system.cancel_se)
        $scene = Scene_Map.new
        return @open = nil
      elsif Input.trigger?(Input::C)
        $game_system.se_play($data_system.decision_se)
      end
    end
  end
  MapData.parse_shires_map_data
end
class Game_System
  alias :kyon_lords_gm_sys_init :initialize
  def initialize
    kyon_lords_gm_sys_init
    setup_klords
    next_shires_map
  end
  def setup_klords
    @klords_setup = KLords::Setup.new
    @lords = { 0 => KLords::Lord.new(0), 1 => KLords::Lord.new(1) }
    @lords[1].name = @klords_setup.temp_name if @klords_setup.need_name
    data = KLords::DATE
    new_calendar(data[:season], data[:year])
  end
  def next_shires_map
    @last_shire_id = nil
    @klords_setup.pos += 1
    @shires_map = KLords::MapData.shires_map(@klords_setup.pos)
    @shires = @shires_map.shires.dup
  end
  def new_calendar(season, year)
    @calendar = KLords::Kalender.new(season, year)
  end
  def shire_change_lord(sid, lid)
    @shires[sid].lord_id = lid
    @lords[lid].add_shire(sid)
  end
  def last_shire() @last_shire_id ? @shires[@last_shire_id] : @shires[0] end
  def bgm_replay() bgm_play(@playing_bgm) end
  def map_id() @klords_setup.pos end
  def lord(lid) @lords[lid] end
  def lord_name(lid) @lords[lid].name end
  def lord_shires(lid) @lords[lid].shires end
  def lord_allies(lid) @lords[lid].allies end
  def lord_crowns(lid) @lords[lid].crowns end
  def lord_gain_crowns(lid, n) @lords[lid].crowns += n end
  def lord_lose_crowns(lid, n) @lords[lid].crowns -= n end
  def lord_resources(lid) @lords[lid].resources end
  def lord_player_victory!() @lords[1].victories += 1 end
  def shire(sid) @shires[sid] end
  def shire_land_id(sid) @shires[sid].land_id end
  def shire_lord_id(sid) @shires[sid].lord_id end
  def shire_tax(sid) @shires[sid].tax end
  def need_player_name?() @klords_setup.need_name end
  def has_player_name!() @klords_setup.need_name = nil end
  attr_reader :calendar, :lords, :shires, :shire_id, :last_shire_id
  #def change_lord(lid, rid) @lords[mid] = rid end
end
class Game_Party
  def leader_as_lord() $game_system.lord(1).name = @actors[0].name end
end
class Interpreter
  def open_klords_map(map_id)
    if $game_system.need_player_name?
      $game_system.has_player_name!
      $scene = KLords::NameScene.new
    else
      $scene = KLords::MapScene.new
    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.
![[Image: SP1-Scripter.png]](https://www.save-point.org/images/userbars/SP1-Scripter.png)
![[Image: SP1-Writer.png]](https://www.save-point.org/images/userbars/SP1-Writer.png)
![[Image: SP1-Poet.png]](https://www.save-point.org/images/userbars/SP1-Poet.png)
![[Image: SP1-PixelArtist.png]](https://www.save-point.org/images/userbars/SP1-PixelArtist.png)
![[Image: SP1-Reporter.png]](https://i.postimg.cc/GmxWbHyL/SP1-Reporter.png)
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.
![[Image: SP1-Scripter.png]](https://www.save-point.org/images/userbars/SP1-Scripter.png)
![[Image: SP1-Writer.png]](https://www.save-point.org/images/userbars/SP1-Writer.png)
![[Image: SP1-Poet.png]](https://www.save-point.org/images/userbars/SP1-Poet.png)
![[Image: SP1-PixelArtist.png]](https://www.save-point.org/images/userbars/SP1-PixelArtist.png)
![[Image: SP1-Reporter.png]](https://i.postimg.cc/GmxWbHyL/SP1-Reporter.png)
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

 
 
 What's up, RMers?
 What's up, RMers?
 

