mirror of
https://github.com/git-learning-game/oh-my-git.git
synced 2024-11-20 16:20:18 +01:00
Show win states in level description
This commit is contained in:
parent
9cfbd9ff96
commit
34841c496b
2 changed files with 23 additions and 10 deletions
|
@ -103,15 +103,13 @@ func construct():
|
||||||
game.global_shell.run(repo.setup_commands)
|
game.global_shell.run(repo.setup_commands)
|
||||||
|
|
||||||
func check_win():
|
func check_win():
|
||||||
var won = true
|
var win_states = {}
|
||||||
var any_checked = false
|
|
||||||
for r in repos:
|
for r in repos:
|
||||||
var repo = repos[r]
|
var repo = repos[r]
|
||||||
if repo.win_conditions.size() > 0:
|
if repo.win_conditions.size() > 0:
|
||||||
any_checked = true
|
|
||||||
game.global_shell.cd(repo.path)
|
game.global_shell.cd(repo.path)
|
||||||
for description in repo.win_conditions:
|
for description in repo.win_conditions:
|
||||||
var commands = repo.win_conditions[description]
|
var commands = repo.win_conditions[description]
|
||||||
if not game.global_shell.run("function win { %s\n}; win 2>/dev/null >/dev/null && echo yes || echo no" % commands) == "yes\n":
|
var won = game.global_shell.run("function win { %s\n}; win 2>/dev/null >/dev/null && echo yes || echo no" % commands) == "yes\n"
|
||||||
won = false
|
win_states[description] = won
|
||||||
return won and any_checked
|
return win_states
|
||||||
|
|
|
@ -96,6 +96,8 @@ func load_level(level_id):
|
||||||
terminal.clear()
|
terminal.clear()
|
||||||
terminal.find_node("TextEditor").close()
|
terminal.find_node("TextEditor").close()
|
||||||
|
|
||||||
|
update_repos()
|
||||||
|
|
||||||
# Unmute the audio after a while, so that player can hear pop sounds for
|
# Unmute the audio after a while, so that player can hear pop sounds for
|
||||||
# nodes they create.
|
# nodes they create.
|
||||||
var t = Timer.new()
|
var t = Timer.new()
|
||||||
|
@ -108,6 +110,7 @@ func load_level(level_id):
|
||||||
|
|
||||||
chapter_select.select(current_chapter)
|
chapter_select.select(current_chapter)
|
||||||
level_select.select(current_level)
|
level_select.select(current_level)
|
||||||
|
|
||||||
|
|
||||||
func reload_level():
|
func reload_level():
|
||||||
levels.reload()
|
levels.reload()
|
||||||
|
@ -117,8 +120,16 @@ func load_next_level():
|
||||||
current_level = (current_level + 1) % levels.chapters[current_chapter].levels.size()
|
current_level = (current_level + 1) % levels.chapters[current_chapter].levels.size()
|
||||||
load_level(current_level)
|
load_level(current_level)
|
||||||
|
|
||||||
func show_win_status():
|
func show_win_status(win_states):
|
||||||
if not level_congrats.visible:
|
var all_won = true
|
||||||
|
var win_text = "\n\n"
|
||||||
|
for state in win_states:
|
||||||
|
win_text += "%s: %s\n" % [state, win_states[state]]
|
||||||
|
if not win_states[state]:
|
||||||
|
all_won = false
|
||||||
|
level_description.text = levels.chapters[current_chapter].levels[current_level].description + win_text
|
||||||
|
|
||||||
|
if not level_congrats.visible and all_won and win_states.size() > 0:
|
||||||
next_level_button.show()
|
next_level_button.show()
|
||||||
level_description.hide()
|
level_description.hide()
|
||||||
level_congrats.show()
|
level_congrats.show()
|
||||||
|
@ -145,8 +156,12 @@ func update_repos():
|
||||||
file_browser.update()
|
file_browser.update()
|
||||||
index.update()
|
index.update()
|
||||||
|
|
||||||
if levels.chapters[current_chapter].levels[current_level].check_win():
|
#if levels.chapters[current_chapter].levels[current_level].check_win():
|
||||||
show_win_status()
|
# show_win_status()
|
||||||
|
|
||||||
|
var win_states = levels.chapters[current_chapter].levels[current_level].check_win()
|
||||||
|
show_win_status(win_states)
|
||||||
|
|
||||||
|
|
||||||
func toggle_cards():
|
func toggle_cards():
|
||||||
cards.visible = not cards.visible
|
cards.visible = not cards.visible
|
||||||
|
|
Loading…
Reference in a new issue