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)
|
||||
|
||||
func check_win():
|
||||
var won = true
|
||||
var any_checked = false
|
||||
var win_states = {}
|
||||
for r in repos:
|
||||
var repo = repos[r]
|
||||
if repo.win_conditions.size() > 0:
|
||||
any_checked = true
|
||||
game.global_shell.cd(repo.path)
|
||||
for description in repo.win_conditions:
|
||||
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":
|
||||
won = false
|
||||
return won and any_checked
|
||||
var won = game.global_shell.run("function win { %s\n}; win 2>/dev/null >/dev/null && echo yes || echo no" % commands) == "yes\n"
|
||||
win_states[description] = won
|
||||
return win_states
|
||||
|
|
|
@ -96,6 +96,8 @@ func load_level(level_id):
|
|||
terminal.clear()
|
||||
terminal.find_node("TextEditor").close()
|
||||
|
||||
update_repos()
|
||||
|
||||
# Unmute the audio after a while, so that player can hear pop sounds for
|
||||
# nodes they create.
|
||||
var t = Timer.new()
|
||||
|
@ -108,6 +110,7 @@ func load_level(level_id):
|
|||
|
||||
chapter_select.select(current_chapter)
|
||||
level_select.select(current_level)
|
||||
|
||||
|
||||
func reload_level():
|
||||
levels.reload()
|
||||
|
@ -117,8 +120,16 @@ func load_next_level():
|
|||
current_level = (current_level + 1) % levels.chapters[current_chapter].levels.size()
|
||||
load_level(current_level)
|
||||
|
||||
func show_win_status():
|
||||
if not level_congrats.visible:
|
||||
func show_win_status(win_states):
|
||||
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()
|
||||
level_description.hide()
|
||||
level_congrats.show()
|
||||
|
@ -145,8 +156,12 @@ func update_repos():
|
|||
file_browser.update()
|
||||
index.update()
|
||||
|
||||
if levels.chapters[current_chapter].levels[current_level].check_win():
|
||||
show_win_status()
|
||||
#if levels.chapters[current_chapter].levels[current_level].check_win():
|
||||
# show_win_status()
|
||||
|
||||
var win_states = levels.chapters[current_chapter].levels[current_level].check_win()
|
||||
show_win_status(win_states)
|
||||
|
||||
|
||||
func toggle_cards():
|
||||
cards.visible = not cards.visible
|
||||
|
|
Loading…
Reference in a new issue