пробуем новый синтаксис глаголов

This commit is contained in:
Alexander Yakovlev 2020-12-24 00:33:56 +07:00
parent 316feb95b9
commit f0bd61722e
Signed by: oreolek
GPG key ID: 1CDC4B7820C93BD3
2 changed files with 28 additions and 198 deletions

View file

@ -12,20 +12,4 @@
закрыть сейф
осмотреть вырезатель
взять вырезатель
выставить К
стрелять в пластинку
выставить С
стрелять в пластину
выставить Л
стрелять в платину
взять батарею
вставить батарею в робота
выставить В
стрелять в рукав
вставить руку в робота
включить робота
выставить К
стрелять в булавку
выставить Т
стрелять в щит
юг
стрелять из к вырезателя в пластинку

View file

@ -1,5 +1,6 @@
-- Здесь мы настраиваем парсер.
local mrd = require "morph/mrd"
local msg = dprint or print
mp.msg.SCENE = "{#Me} {#plural/находишься,находитесь} {#if_has/#here,supporter,на,в} {#here/пр,2}.";
mp.msg.Exam.DEFAULT = "{#Me} не {#g/видишь,видите} {#vo/{#first/пр}} ничего необычного.";
@ -116,11 +117,8 @@ end
Verb {
"#Shoot",
'стрел/ять,вырез/ать',
-- дань удобству - можно опустить предлог
'~ {noun}/вн,scene : LetterShoot',
'~ в|во {noun}/вн,scene : LetterShoot',
'~ из {noun}/рд в|во {noun}/вн,scene : LetterShoot',
'~ из {noun}/тв,scene : WrongShoot',
'~ из *вырезате/ля в/о {noun}/вн,scene : SetShoot',
'~ из * вырезате/ля в/о {noun}/вн,scene : SetShoot',
}
function HasChar(str, skipc)
@ -137,29 +135,37 @@ function StrCut(str, skipc)
return str:gsub(skipc, '')
end
function mp:WrongShoot(w)
return 'Правильная команда: стрелять (во что-то)';
end
function mp:LetterShoot(w)
function mp:SetShoot(what, e, f, g, letter)
msg(what)
msg(e)
msg(f)
msg(g)
msg(letter)
if not pl:have('letterremover') then
return 'Нечем.';
end
if (w:has 'animate') then
if (what:has 'animate') then
return 'Вырезатель не работает на живых.';
end
if (w:has 'essential') then
if (what:has 'essential') then
return 'Это слишком полезная вещь, чтобы её вырезать.';
end
local letter = _('letterremover').letter;
if type(letter) ~= 'string' then
return 'Вырезатель можно установить только на букву русского алфавита.';
end
letter = letter:gsub("%s", "");
letter = letter:gsub("-", "");
if string.len(w) > 1 then
return 'Вырезатель можно установить только на одну букву.';
end
local lcaseletter = mrd.lang.lower(letter);
if w.canonical == nil or w.canonical == '' then
w.canonical = w.word
if what.canonical == nil or what.canonical == '' then
what.canonical = what.word
end
if not HasChar(w.canonical, lcaseletter) then
return 'Вырезатель настроен на букву '..letter..', которой нет в слове «'..w.canonical..'».';
if not HasChar(what.canonical, lcaseletter) then
return 'Вырезатель настроен на букву '..letter..', которой нет в слове «'..what.canonical..'».';
end
local newCanonical = StrCut(w.canonical, lcaseletter);
local newCanonical = StrCut(what.canonical, lcaseletter);
local newTarget = lookup(newCanonical);
if not newTarget then
-- продолжаем поиск полным перебором
@ -171,174 +177,14 @@ function mp:LetterShoot(w)
end)
end
if newTarget then
w:remove();
what:remove();
put(newTarget, here());
pn('Вы стреляете в '.. w:noun'вн' ..',и это вырезается в '..newCanonical..'.');
pn('Вы стреляете в '.. what:noun'вн' ..',и это вырезается в '..newCanonical..'.');
if newTarget.oncreate ~= nil then
newTarget.oncreate()
end
return;
end
return 'Вы стреляете в '.. w:noun'вн' ..' и это мигает в слабом тумане букв «'..newCanonical..'», но затем возвращается в прежнее состояние.';
end
return 'Вы стреляете в '.. what:noun'вн' ..' и '..what:it('им')..' мигает в слабом тумане букв «'..newCanonical..'», но затем возвращается в прежнее состояние.';
Verb {
"#Set",
'установ/ить,выстав/ить',
-- см. проблему #3 - я не хочу определять ещё 33*4 вариации
--'~ вырезатель на А: LetterSetA',
--'~ вырезатель на а: LetterSetA',
--'~ а на вырезателе: LetterSetA',
--'~ А на вырезателе: LetterSetA',
'~ А: LetterSet1',
'~ Б: LetterSet2',
'~ В: LetterSet3',
'~ Г: LetterSet4',
'~ Д: LetterSet5',
'~ Е: LetterSet6',
'~ Ё: LetterSet7',
'~ Ж: LetterSet8',
'~ З: LetterSet9',
'~ И: LetterSet10',
'~ Й: LetterSet11',
'~ К: LetterSet12',
'~ Л: LetterSet13',
'~ М: LetterSet14',
'~ Н: LetterSet15',
'~ О: LetterSet16',
'~ П: LetterSet17',
'~ Р: LetterSet18',
'~ С: LetterSet19',
'~ Т: LetterSet20',
'~ У: LetterSet21',
'~ Ф: LetterSet22',
'~ Х: LetterSet23',
'~ Ц: LetterSet24',
'~ Ч: LetterSet25',
'~ Ш: LetterSet26',
'~ Щ: LetterSet27',
'~ Ъ: LetterSet28',
'~ Ы: LetterSet29',
'~ Ь: LetterSet30',
'~ Э: LetterSet31',
'~ Ю: LetterSet32',
'~ Я: LetterSet33',
}
function mp:LetterSet(w)
if not pl:have('letterremover') then
return 'Нечем.';
end
if type(w) ~= 'string' then
return 'Вырезатель можно установить только на букву русского алфавита.';
end
--if string.len(w) > 1 then
-- return 'Вырезатель можно установить только на одну букву.';
--end
local letter = _('letterremover').letter;
if letter ~= w then
_('letterremover').letter = w
return 'Вырезатель будет вынимать букву '..w..'.';
end
return 'Вырезатель уже работает на частоте буквы '..w;
end
function mp:LetterSet1()
return mp:LetterSet('А')
end
function mp:LetterSet2()
return mp:LetterSet('Б')
end
function mp:LetterSet3()
return mp:LetterSet('В')
end
function mp:LetterSet4()
return mp:LetterSet('Г')
end
function mp:LetterSet5()
return mp:LetterSet('Д')
end
function mp:LetterSet6()
return mp:LetterSet('Е')
end
function mp:LetterSet7()
return mp:LetterSet('Ё')
end
function mp:LetterSet8()
return mp:LetterSet('Ж')
end
function mp:LetterSet9()
return mp:LetterSet('З')
end
function mp:LetterSet10()
return mp:LetterSet('И')
end
function mp:LetterSet11()
return mp:LetterSet('Й')
end
function mp:LetterSet12()
return mp:LetterSet('К')
end
function mp:LetterSet13()
return mp:LetterSet('Л')
end
function mp:LetterSet14()
return mp:LetterSet('М')
end
function mp:LetterSet15()
return mp:LetterSet('Н')
end
function mp:LetterSet16()
return mp:LetterSet('О')
end
function mp:LetterSet17()
return mp:LetterSet('П')
end
function mp:LetterSet18()
return mp:LetterSet('Р')
end
function mp:LetterSet19()
return mp:LetterSet('С')
end
function mp:LetterSet20()
return mp:LetterSet('Т')
end
function mp:LetterSet21()
return mp:LetterSet('У')
end
function mp:LetterSet22()
return mp:LetterSet('Ф')
end
function mp:LetterSet23()
return mp:LetterSet('Х')
end
function mp:LetterSet24()
return mp:LetterSet('Ц')
end
function mp:LetterSet25()
return mp:LetterSet('Ч')
end
function mp:LetterSet26()
return mp:LetterSet('Ш')
end
function mp:LetterSet27()
return mp:LetterSet('Щ')
end
function mp:LetterSet28()
return mp:LetterSet('Ъ')
end
function mp:LetterSet29()
return mp:LetterSet('Ы')
end
function mp:LetterSet30()
return mp:LetterSet('Ь')
end
function mp:LetterSet31()
return mp:LetterSet('Э')
end
function mp:LetterSet32()
return mp:LetterSet('Ю')
end
function mp:LetterSet33()
return mp:LetterSet('Я')
end