Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .editorconfig
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you format the code with stylua? if so, could you add stylua.toml instead of .editorconfig?

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
root = true

[*]
indent_style = space
indent_size = 2
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

**This plugin is still under the development!***

Currently starts in Neovim v0.10.3

# rogue.vim

_"Hello Vimmer, welcome to the Dungeons of Doom..."_
Expand All @@ -26,7 +28,7 @@ https://github.com/4513ECHO/rogue.nvim

## Requirements

rogue.nvim requires Neovim 0.7.0 or later. This is not working on Vim.
rogue.nvim works in Neovim 0.10.3 but not tested on earlier versions

## Acknowledgments

Expand Down
2 changes: 1 addition & 1 deletion lua/rogue/const.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local g = Rogue -- alias
local g = require("rogue.main")

g.print_enum = {}

Expand Down
16 changes: 8 additions & 8 deletions lua/rogue/curses.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local g = Rogue -- alias
local util = require "rogue.util"
local g = require("rogue.main")
local util = require("rogue.util")

g.COLOR = true

Expand Down Expand Up @@ -75,7 +75,7 @@ function g.mvaddstr(row, col, str)
end

function g.refresh()
vim.cmd "normal gg"
vim.cmd("normal gg")
local update = false
local done_redraw = false
for i = 0, g.DROWS - 1 do
Expand All @@ -89,15 +89,15 @@ function g.refresh()
if i == g.DROWS - 1 and vim.o.lines == g.DROWS then
row_str = row_str .. dungeon_str_buffer[i].str
if g.update_flag or row_str ~= last_print_area then
vim.cmd "redraw"
print((vim.fn.has "gui_running" ~= 0 and "" or " ") .. row_str)
vim.cmd "redrawstatus"
vim.cmd("redraw")
print((vim.fn.has("gui_running") ~= 0 and "" or " ") .. row_str)
vim.cmd("redrawstatus")
last_print_area = row_str
done_redraw = true
end
else
if g.update_flag and i == 0 and vim.o.lines > g.DROWS then
print " "
print(" ")
end
if dungeon_str_buffer[i].str ~= "" then
if g.COLOR then
Expand All @@ -121,6 +121,6 @@ function g.refresh()
end
g.update_flag = false
if update and not done_redraw then
vim.cmd "redraw"
vim.cmd("redraw")
end
end
15 changes: 7 additions & 8 deletions lua/rogue/debug.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
local g = Rogue -- alias
local util = require "rogue.util"
local g = require("rogue.main")
local Rogue = require("rogue.main")
local util = require("rogue.util")

g.DEBUG = true
-- g.COVERAGE = true
Expand Down Expand Up @@ -183,8 +184,8 @@ function g.breakpoint(log_flag)
if input == "" then
break
end
g.printf " \n"
local idx = input:find "="
g.printf(" \n")
local idx = input:find("=")
if idx then
-- set value
local obj = input:sub(1, idx - 1)
Expand Down Expand Up @@ -223,9 +224,7 @@ function g.__FILE_LINE__(level)
else
level = level + 1
end
return string.gsub(debug.getinfo(level, "S").source, "^@", "")
.. ":"
.. debug.getinfo(level, "l").currentline
return string.gsub(debug.getinfo(level, "S").source, "^@", "") .. ":" .. debug.getinfo(level, "l").currentline
end

function g.log_screen()
Expand All @@ -250,7 +249,7 @@ end

local function cov_hook(event, line)
local s = string.gsub(debug.getinfo(2, "S").source, "^@", "")
if not s:find "%.lua$" then
if not s:find("%.lua$") then
return
end
if not cov_data[s] then
Expand Down
27 changes: 9 additions & 18 deletions lua/rogue/hit.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local g = Rogue -- alias
local mesg = require "rogue.mesg"
local random = require "rogue.random"
local util = require "rogue.util"
local g = require("rogue.main")
local mesg = require("rogue.mesg")
local random = require("rogue.random")
local util = require("rogue.util")

g.hit_message = ""
local fight_monster = nil
Expand All @@ -27,8 +27,7 @@ function g.mon_hit(monster, other, flame)
hit_chance = 100
else
hit_chance = monster.m_hit_chance
hit_chance = hit_chance
- (((2 * g.rogue.exp) + (2 * g.ring_exp)) - g.r_rings)
hit_chance = hit_chance - (((2 * g.rogue.exp) + (2 * g.ring_exp)) - g.r_rings)
end
if g.wizard then
hit_chance = util.int_div(hit_chance, 2)
Expand All @@ -44,8 +43,7 @@ function g.mon_hit(monster, other, flame)

if not random.rand_percent(hit_chance) then
if not fight_monster then
g.hit_message = g.hit_message
.. string.format(mesg[18], (other and other or mn))
g.hit_message = g.hit_message .. string.format(mesg[18], (other and other or mn))
g.message(g.hit_message, true)
g.hit_message = ""
end
Expand Down Expand Up @@ -230,10 +228,7 @@ function g.fight(to_the_death)
row, col = g.get_dir_rc(ch, row, col, false)

local c = g.mvinch(row, col)
if
not c:find "^[A-Z]$"
or not g.can_move(g.rogue.row, g.rogue.col, row, col)
then
if not c:find("^[A-Z]$") or not g.can_move(g.rogue.row, g.rogue.col, row, col) then
g.message(mesg[25])
return
end
Expand All @@ -243,10 +238,7 @@ function g.fight(to_the_death)
end
local possible_damage
if not fight_monster.m_flags[g.STATIONARY] then
possible_damage = util.int_div(
(g.get_damage(fight_monster.m_damage, false) * 2),
3
)
possible_damage = util.int_div((g.get_damage(fight_monster.m_damage, false) * 2), 3)
else
possible_damage = fight_monster.stationary_damage - 1
end
Expand Down Expand Up @@ -317,7 +309,6 @@ end

function g.get_weapon_damage(weapon)
local damage = get_w_damage(weapon) + damage_for_strength()
damage = damage
+ util.int_div((((g.rogue.exp + g.ring_exp) - g.r_rings) + 1), 2)
damage = damage + util.int_div((((g.rogue.exp + g.ring_exp) - g.r_rings) + 1), 2)
return damage
end
15 changes: 6 additions & 9 deletions lua/rogue/init.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local g = Rogue -- alias
local mesg = require "rogue.mesg"
local random = require "rogue.random"
local g = require("rogue.main")
local mesg = require("rogue.mesg")
local random = require("rogue.random")

g.nick_name = ""
g.score_only = false
Expand All @@ -13,10 +13,7 @@ g.do_restore = false
local rest_file = nil

local function set_nick_name()
g.nick_name = vim.g["rogue#name"]
or os.getenv "FIGHTER"
or os.getenv "USER"
or os.getenv "USERNAME"
g.nick_name = vim.g["rogue#name"] or os.getenv("FIGHTER") or os.getenv("USER") or os.getenv("USERNAME")
local default_name = mesg[542]
vim.ui.input({ prompt = mesg[13], default = default_name }, function(input)
if input == "" then
Expand Down Expand Up @@ -163,8 +160,8 @@ function g.init(args)

do_args(args)
if g.score_only then
g.message ""
print ""
g.message("")
print("")
g.put_scores(nil, 0)
-- NOTREACHED
end
Expand Down
35 changes: 9 additions & 26 deletions lua/rogue/invent.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local g = Rogue -- alias
local mesg = require "rogue.mesg"
local random = require "rogue.random"
local util = require "rogue.util"
local g = require("rogue.main")
local mesg = require("rogue.mesg")
local random = require("rogue.random")
local util = require("rogue.util")

g.is_wood = {}

Expand Down Expand Up @@ -134,11 +134,7 @@ function g.inventory(pack, mask)
local maxlen = len
while obj and i < g.DROWS - 2 do
if mask[obj.what_is] then
g.descs[i] = " "
.. obj.ichar
.. (Protected(obj) and "}" or ")")
.. " "
.. g.get_desc(obj, false)
g.descs[i] = " " .. obj.ichar .. (Protected(obj) and "}" or ")") .. " " .. g.get_desc(obj, false)
local n = util.strwidth(g.descs[i])
if n > maxlen then
maxlen = n
Expand Down Expand Up @@ -177,8 +173,7 @@ function g.mix_colors()
end
for i = 0, g.POTIONS - 1 do
local j = random.get_rand(i, g.POTIONS - 1)
g.id_potions[i].title, g.id_potions[j].title =
g.id_potions[j].title, g.id_potions[i].title
g.id_potions[i].title, g.id_potions[j].title = g.id_potions[j].title, g.id_potions[i].title
end
end

Expand Down Expand Up @@ -293,12 +288,7 @@ function g.get_desc(obj, capitalized)
if g.wizard then
-- goto ID
goto_ID_flag = true
elseif
obj.what_is == g.WEAPON
or obj.what_is == g.ARMOR
or obj.what_is == g.WAND
or obj.what_is == g.RING
then
elseif obj.what_is == g.WEAPON or obj.what_is == g.ARMOR or obj.what_is == g.WAND or obj.what_is == g.RING then
-- goto CHECK
goto_CHECK_flag = true
end
Expand Down Expand Up @@ -354,9 +344,7 @@ function g.get_desc(obj, capitalized)
desc = desc .. id_table[obj.which_kind].real
end
if g.wizard or obj.identified then
if
obj.which_kind == g.DEXTERITY or obj.which_kind == g.ADD_STRENGTH
then
if obj.which_kind == g.DEXTERITY or obj.which_kind == g.ADD_STRENGTH then
desc = desc .. mesg[537] .. g.znum(obj.class, true) .. mesg[538]
end
end
Expand Down Expand Up @@ -384,12 +372,7 @@ function g.get_desc(obj, capitalized)
end
elseif goto_CALL_flag or (not goto_CHECK_flag and id_status == g.CALLED) then
-- ::CALL::
if
obj.what_is == g.SCROL
or obj.what_is == g.POTION
or obj.what_is == g.WAND
or obj.what_is == g.RING
then
if obj.what_is == g.SCROL or obj.what_is == g.POTION or obj.what_is == g.WAND or obj.what_is == g.RING then
if mesg.JAPAN then
desc = desc .. id_table[obj.which_kind].title .. mesg[34] .. item_name
else
Expand Down
Loading