<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<el:level xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://enigma-game.org/schema/level/1 level.xsd" xmlns:el="http://enigma-game.org/schema/level/1">
  <el:protected>
    <el:info el:type="level">
      <el:identity el:title="Blet" el:subtitle="" el:id="alain24"/>
      <el:version el:score="1" el:release="2" el:revision="2" el:status="released"/>
      <el:author  el:name="Alain Busser" el:email="" el:homepage=""/>
      <el:copyright>Copyright © 2006 Alain Busser</el:copyright>
      <el:license el:type="GPL v2.0 or above" el:open="true"/>
      <el:compatibility el:enigma="1.10"/>
      <el:modes el:easy="true" el:single="true" el:network="false"/>
      <el:comments><el:code>New API converted by R. Bourquin</el:code></el:comments>
      <el:score el:easy="1:24" el:difficult="0:28"/>
    </el:info>
    <el:luamain><![CDATA[
ti[" "] = {"fl_blueslab"}
ti["r"] = {"fl_red", name="red#", _other="g"}
ti["g"] = {"fl_lawn", name="green#", _other="r"}
ti[">"] = {"st_laser", orientation=EAST, name="laser"}
ti["<"] = {"st_mirror", flavor="triangle", orientation=WEST}
ti["M"] = {"st_mirror", orientation=SLASH}
ti["N"] = {"st_mirror", orientation=BACKSLASH}
ti["S"] = {"st_switch", target="change"}
ti["d"] = {"it_document", text="text1"}
ti["e"] = cond(wo["IsDifficult"], {"it_document", text="text2"}, ti[" "])
ti["O"] = {"st_oxyd"}
ti["@"] = {"ac_marble_black"}

wo(ti, " ", {
    "     r  g      MNMNO",
    "   g      r         ",
    "  r   SS   g        ",
    "     S  S           ",
    " g  S    S  r   NMNM",
    "   S      S   ><    ",
    "   S  d@  S     MNMN",
    " r  S e  S  g       ",
    "     S  S           ",
    "  g   SS   r        ",
    "   r      g         ",
    "     g  r      NMNMO"})

function change(value, sender)
    all = no["red#*"] + no["green#*"]
    cen = all:nearest(sender)
    left = (all-cen):nearest(cen)
    right = (all-cen-left):nearest(cen)
    if not wo["IsDifficult"] or
       (no["red#*"][cen] and no["green#*"][left] and no["green#*"][right] or
        no["green#*"][cen] and no["red#*"][left] and no["red#*"][right]) then
        wo[cen] = ti[cen["_other"]]
        wo[left] = ti[left["_other"]]
        wo[right] = ti[right["_other"]]
    end
    if #no["red#*"] == 0 or (wo["IsDifficult"] and #no["red#*"] == 3) then
        no["laser"]:on()
    end
end
 ]]></el:luamain>
    <el:i18n>
      <el:string el:key="title">
        <el:english el:translate="false"/>
      </el:string>
      <el:string el:key="text1">
        <el:english el:translate="true">When you change the color of one square, the colors of the 2 nearest squares change as well; you must get as many green squares as possible.</el:english>
        <el:translation el:lang="fr">En changeant la couleur d'une pastille, les deux pastilles adjacentes changent aussi de couleur; le but du jeu est d'obtenir le plus grand nombre possible de pastilles vertes.</el:translation>
      </el:string>
      <el:string el:key="text2">
        <el:english el:translate="true">You are only allowed to change a color when it is surrounded by the other color.</el:english>
        <el:translation el:lang="fr">Vous ne pouvez changer une pastille que dans l'un des deux cas suivants: rouge-vert-rouge, ou vert-rouge-vert.</el:translation>
      </el:string>
    </el:i18n>
  </el:protected>
</el:level>
