|
|
|
@ -3,6 +3,7 @@ import GameServer.Inventory
|
|
|
|
import GameServer.Options
|
|
|
|
import GameServer.Options
|
|
|
|
import GameServer.SaveData
|
|
|
|
import GameServer.SaveData
|
|
|
|
import GameServer.Hints
|
|
|
|
import GameServer.Hints
|
|
|
|
|
|
|
|
import I18n
|
|
|
|
|
|
|
|
|
|
|
|
open Lean Meta Elab Command
|
|
|
|
open Lean Meta Elab Command
|
|
|
|
|
|
|
|
|
|
|
|
@ -33,16 +34,17 @@ elab "Level" level:num : command => do
|
|
|
|
|
|
|
|
|
|
|
|
/-- Define the title of the current game/world/level. -/
|
|
|
|
/-- Define the title of the current game/world/level. -/
|
|
|
|
elab "Title" t:str : command => do
|
|
|
|
elab "Title" t:str : command => do
|
|
|
|
|
|
|
|
let title ← t.getString.translate
|
|
|
|
match ← getCurLayer with
|
|
|
|
match ← getCurLayer with
|
|
|
|
| .Level => modifyCurLevel fun level => pure {level with title := t.getString}
|
|
|
|
| .Level => modifyCurLevel fun level => pure {level with title := title}
|
|
|
|
| .World => modifyCurWorld fun world => pure {world with title := t.getString}
|
|
|
|
| .World => modifyCurWorld fun world => pure {world with title := title}
|
|
|
|
| .Game => modifyCurGame fun game => pure {game with
|
|
|
|
| .Game => modifyCurGame fun game => pure {game with
|
|
|
|
title := t.getString
|
|
|
|
title := t.getString
|
|
|
|
tile := {game.tile with title := t.getString}}
|
|
|
|
tile := {game.tile with title := title}}
|
|
|
|
|
|
|
|
|
|
|
|
/-- Define the introduction of the current game/world/level. -/
|
|
|
|
/-- Define the introduction of the current game/world/level. -/
|
|
|
|
elab "Introduction" t:str : command => do
|
|
|
|
elab "Introduction" t:str : command => do
|
|
|
|
let intro := t.getString
|
|
|
|
let intro ← t.getString.translate
|
|
|
|
match ← getCurLayer with
|
|
|
|
match ← getCurLayer with
|
|
|
|
| .Level => modifyCurLevel fun level => pure {level with introduction := intro}
|
|
|
|
| .Level => modifyCurLevel fun level => pure {level with introduction := intro}
|
|
|
|
| .World => modifyCurWorld fun world => pure {world with introduction := intro}
|
|
|
|
| .World => modifyCurWorld fun world => pure {world with introduction := intro}
|
|
|
|
@ -50,7 +52,7 @@ elab "Introduction" t:str : command => do
|
|
|
|
|
|
|
|
|
|
|
|
/-- Define the info of the current game. Used for e.g. credits -/
|
|
|
|
/-- Define the info of the current game. Used for e.g. credits -/
|
|
|
|
elab "Info" t:str : command => do
|
|
|
|
elab "Info" t:str : command => do
|
|
|
|
let info:= t.getString
|
|
|
|
let info ← t.getString.translate
|
|
|
|
match ← getCurLayer with
|
|
|
|
match ← getCurLayer with
|
|
|
|
| .Level =>
|
|
|
|
| .Level =>
|
|
|
|
logError "Can't use `Info` in a level!"
|
|
|
|
logError "Can't use `Info` in a level!"
|
|
|
|
@ -82,7 +84,7 @@ elab "Image" t:str : command => do
|
|
|
|
/-- Define the conclusion of the current game or current level if some
|
|
|
|
/-- Define the conclusion of the current game or current level if some
|
|
|
|
building a level. -/
|
|
|
|
building a level. -/
|
|
|
|
elab "Conclusion" t:str : command => do
|
|
|
|
elab "Conclusion" t:str : command => do
|
|
|
|
let conclusion := t.getString
|
|
|
|
let conclusion ← t.getString.translate
|
|
|
|
match ← getCurLayer with
|
|
|
|
match ← getCurLayer with
|
|
|
|
| .Level => modifyCurLevel fun level => pure {level with conclusion := conclusion}
|
|
|
|
| .Level => modifyCurLevel fun level => pure {level with conclusion := conclusion}
|
|
|
|
| .World => modifyCurWorld fun world => pure {world with conclusion := conclusion}
|
|
|
|
| .World => modifyCurWorld fun world => pure {world with conclusion := conclusion}
|
|
|
|
@ -95,13 +97,13 @@ elab "Prerequisites" t:str* : command => do
|
|
|
|
|
|
|
|
|
|
|
|
/-- Short caption for the game (1 sentence) -/
|
|
|
|
/-- Short caption for the game (1 sentence) -/
|
|
|
|
elab "CaptionShort" t:str : command => do
|
|
|
|
elab "CaptionShort" t:str : command => do
|
|
|
|
let caption := t.getString
|
|
|
|
let caption ← t.getString.translate
|
|
|
|
modifyCurGame fun game => pure {game with
|
|
|
|
modifyCurGame fun game => pure {game with
|
|
|
|
tile := {game.tile with short := caption}}
|
|
|
|
tile := {game.tile with short := caption}}
|
|
|
|
|
|
|
|
|
|
|
|
/-- More detailed description what the game is about (2-4 sentences). -/
|
|
|
|
/-- More detailed description what the game is about (2-4 sentences). -/
|
|
|
|
elab "CaptionLong" t:str : command => do
|
|
|
|
elab "CaptionLong" t:str : command => do
|
|
|
|
let caption := t.getString
|
|
|
|
let caption ← t.getString.translate
|
|
|
|
modifyCurGame fun game => pure {game with
|
|
|
|
modifyCurGame fun game => pure {game with
|
|
|
|
tile := {game.tile with long := caption}}
|
|
|
|
tile := {game.tile with long := caption}}
|
|
|
|
|
|
|
|
|
|
|
|
@ -142,6 +144,7 @@ TacticDoc rw "`rw` stands for rewrite, etc. "
|
|
|
|
-/
|
|
|
|
-/
|
|
|
|
elab doc:docComment ? "TacticDoc" name:ident content:str ? : command => do
|
|
|
|
elab doc:docComment ? "TacticDoc" name:ident content:str ? : command => do
|
|
|
|
let doc ← parseDocCommentLegacy doc content
|
|
|
|
let doc ← parseDocCommentLegacy doc content
|
|
|
|
|
|
|
|
let doc ← doc.translate
|
|
|
|
modifyEnv (inventoryTemplateExt.addEntry · {
|
|
|
|
modifyEnv (inventoryTemplateExt.addEntry · {
|
|
|
|
type := .Tactic
|
|
|
|
type := .Tactic
|
|
|
|
name := name.getId
|
|
|
|
name := name.getId
|
|
|
|
@ -166,6 +169,7 @@ The theorem/definition to have the same fully qualified name as in mathlib.
|
|
|
|
elab doc:docComment ? "TheoremDoc" name:ident "as" displayName:str "in" category:str content:str ? :
|
|
|
|
elab doc:docComment ? "TheoremDoc" name:ident "as" displayName:str "in" category:str content:str ? :
|
|
|
|
command => do
|
|
|
|
command => do
|
|
|
|
let doc ← parseDocCommentLegacy doc content
|
|
|
|
let doc ← parseDocCommentLegacy doc content
|
|
|
|
|
|
|
|
let doc ← doc.translate
|
|
|
|
modifyEnv (inventoryTemplateExt.addEntry · {
|
|
|
|
modifyEnv (inventoryTemplateExt.addEntry · {
|
|
|
|
type := .Lemma
|
|
|
|
type := .Lemma
|
|
|
|
name := name.getId
|
|
|
|
name := name.getId
|
|
|
|
@ -195,6 +199,7 @@ The theorem/definition to have the same fully qualified name as in mathlib.
|
|
|
|
-/
|
|
|
|
-/
|
|
|
|
elab doc:docComment ? "DefinitionDoc" name:ident "as" displayName:str template:str ? : command => do
|
|
|
|
elab doc:docComment ? "DefinitionDoc" name:ident "as" displayName:str template:str ? : command => do
|
|
|
|
let doc ← parseDocCommentLegacy doc template
|
|
|
|
let doc ← parseDocCommentLegacy doc template
|
|
|
|
|
|
|
|
let doc ← doc.translate
|
|
|
|
modifyEnv (inventoryTemplateExt.addEntry · {
|
|
|
|
modifyEnv (inventoryTemplateExt.addEntry · {
|
|
|
|
type := .Definition
|
|
|
|
type := .Definition
|
|
|
|
name := name.getId,
|
|
|
|
name := name.getId,
|
|
|
|
@ -341,6 +346,9 @@ elab doc:docComment ? attrs:Parser.Term.attributes ?
|
|
|
|
let lvlIdx ← getCurLevelIdx
|
|
|
|
let lvlIdx ← getCurLevelIdx
|
|
|
|
|
|
|
|
|
|
|
|
let docContent ← parseDocComment doc
|
|
|
|
let docContent ← parseDocComment doc
|
|
|
|
|
|
|
|
let docContent ← match docContent with
|
|
|
|
|
|
|
|
| none => pure none
|
|
|
|
|
|
|
|
| some d => d.translate
|
|
|
|
|
|
|
|
|
|
|
|
-- Save the messages before evaluation of the proof.
|
|
|
|
-- Save the messages before evaluation of the proof.
|
|
|
|
let initMsgs ← modifyGet fun st => (st.messages, { st with messages := {} })
|
|
|
|
let initMsgs ← modifyGet fun st => (st.messages, { st with messages := {} })
|
|
|
|
@ -426,6 +434,12 @@ elab doc:docComment ? attrs:Parser.Term.attributes ?
|
|
|
|
strict := strict == 1
|
|
|
|
strict := strict == 1
|
|
|
|
hidden := hidden == 1
|
|
|
|
hidden := hidden == 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Note: The current setup for hints is a bit convoluted, but for now we need to
|
|
|
|
|
|
|
|
-- send the text once through i18n to register it in the env extension.
|
|
|
|
|
|
|
|
-- This could probably be rewritten once i18n works fully.
|
|
|
|
|
|
|
|
let _ ← hint.rawText.translate
|
|
|
|
|
|
|
|
|
|
|
|
hints := hints.push hint
|
|
|
|
hints := hints.push hint
|
|
|
|
else
|
|
|
|
else
|
|
|
|
nonHintMsgs := nonHintMsgs.push msg
|
|
|
|
nonHintMsgs := nonHintMsgs.push msg
|
|
|
|
|