Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mission 3 : adding initial position and error messages #155

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion doc/mission.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ Useful commands
===============

cd PLACE
Move to the given place, if accessible from you current location.
Move to the given place, if accessible from your current location.
```

For uniformity, meta-variables in commands should be in UPPERCASE.
Expand Down
20 changes: 17 additions & 3 deletions missions/basic/03_cd_HOME_throne/check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,23 @@ _mission_check() {

ppc=$(. fc-lnr.sh | sed -n '2p;3q')

# FIXME: also accept other commands to go back to the starting point?
# FIXME: add an error message
[ "$goal" = "$current" ] && [ "$ppc" = "cd" ]
# Accepts only "cd" and "cd ~". "cd ../../../../" and variants are not valid.
if [ "$ppc" != "cd" ] && [ "$ppc" != "cd ~" ]; then
if [ "$ppc" =~ "cd ../*" ]; then
echo "$(gettext "The command to go to the starting point is too complicated.")"
else
echo "$(gettext "The previous to last command must take you to the starting point.")"
fi
return 1
fi

# Verify the current location
if [ "$goal" != "$current" ]; then
echo "$(gettext "You are not in the throne room.")"
return 1
fi

return 0
}

_mission_check
2 changes: 1 addition & 1 deletion missions/basic/03_cd_HOME_throne/goal/fr.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Commandes utiles
================

cd
Revient au lieu initial.
Revient au point de départ.

cd LIEU1/LIEU2/LIEU3
Fait plusieurs déplacements avec une commande.
Expand Down
16 changes: 16 additions & 0 deletions missions/basic/03_cd_HOME_throne/i18n/en.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ msgstr "Content-Type: text/plain; charset=UTF-8\n"
msgid "$GSH_HOME/Castle/Main_building/Throne_room"
msgstr "$GSH_HOME/Castle/Main_building/Throne_room"

msgid "$GSH_HOME/Castle/Cellar"
msgstr "$GSH_HOME/Castle/Cellar"

# path for the text file containing the goal
msgid "$MISSION_DIR/goal/en.txt"
msgstr "$MISSION_DIR/goal/en.txt"
Expand All @@ -18,3 +21,16 @@ msgstr "$MISSION_DIR/skip/en.txt"
# path for the text file containing the treasure message
msgid "$MISSION_DIR/treasure-msg/en.txt"
msgstr "$MISSION_DIR/treasure-msg/en.txt"

# Message for current position
msgid "Current position:"
msgstr "Current position:"

msgid "The command to go to the starting point is too complicated."
msgstr "The command to go to the starting point is too complicated."

msgid "The previous to last command must take you to the starting point."
msgstr "The previous to last command must take you to the starting point."

msgid "You are not in the throne room."
msgstr "You are not in the throne room."
16 changes: 16 additions & 0 deletions missions/basic/03_cd_HOME_throne/i18n/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ msgstr "Content-Type: text/plain; charset=UTF-8\n"
msgid "$GSH_HOME/Castle/Main_building/Throne_room"
msgstr "$GSH_HOME/Chateau/Batiment_principal/Salle_du_trone"

msgid "$GSH_HOME/Castle/Cellar"
msgstr "$GSH_HOME/Chateau/Cave"

# path for the text file containing the goal
msgid "$MISSION_DIR/goal/en.txt"
msgstr "$MISSION_DIR/goal/fr.txt"
Expand All @@ -17,3 +20,16 @@ msgstr "$MISSION_DIR/skip/fr.txt"
# path for the text file containing the treasure message
msgid "$MISSION_DIR/treasure-msg/en.txt"
msgstr "$MISSION_DIR/treasure-msg/fr.txt"

# Message for current position
msgid "Current position:"
msgstr "Position actuelle :"

msgid "The command to go to the starting point is too complicated."
msgstr "La commande pour retourner au point de départ est trop compliquée."

msgid "The previous to last command must take you to the starting point."
msgstr "L'avant-dernière commande doit vous ramener au point de départ."

msgid "You are not in the throne room."
msgstr "Vous n'êtes pas dans la salle du trône."
3 changes: 3 additions & 0 deletions missions/basic/03_cd_HOME_throne/i18n/it.po
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ msgstr ""
msgid "$GSH_HOME/Castle/Main_building/Throne_room"
msgstr "$GSH_HOME/Castello/Palazzo_principale/Sala_del_trono"

msgid "$GSH_HOME/Castle/Cellar"
msgstr "$GSH_HOME/Castello/Cantina"

# path for the text file containing the goal
msgid "$MISSION_DIR/goal/en.txt"
msgstr "$MISSION_DIR/goal/it.txt"
Expand Down
16 changes: 16 additions & 0 deletions missions/basic/03_cd_HOME_throne/i18n/template.pot
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ msgstr "Content-Type: text/plain; charset=UTF-8\n"
msgid "$GSH_HOME/Castle/Main_building/Throne_room"
msgstr ""

msgid "$GSH_HOME/Castle/Cellar"
msgstr ""

# path for the text file containing the goal
msgid "$MISSION_DIR/goal/en.txt"
msgstr ""
Expand All @@ -17,3 +20,16 @@ msgstr ""
# path for the text file containing the treasure message
msgid "$MISSION_DIR/treasure-msg/en.txt"
msgstr ""

# Message for current position
msgid "Current position:"
msgstr ""

msgid "The command to go to the starting point is too complicated."
msgstr ""

msgid "The previous to last command must take you to the starting point."
msgstr ""

msgid "You are not in the throne room."
msgstr ""
4 changes: 4 additions & 0 deletions missions/basic/03_cd_HOME_throne/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh

cd "$(eval_gettext '$GSH_HOME/Castle/Cellar')"
echo "$(gettext "Current position:") $(pwd)"
1 change: 1 addition & 0 deletions missions/basic/03_cd_HOME_throne/static.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env sh

mkdir -p "$(eval_gettext '$GSH_HOME/Castle/Cellar')"
mkdir -p "$(eval_gettext '$GSH_HOME/Castle/Main_building/Throne_room')"