First draft of rules - almost certainly buggy