Move logic to js (outside rpgjs).