Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ca.mcgill.ecse.fairtracks.queries
- import "http://www.mcgill.ca/ecse/fairtracks/FairtracksDsl"
- /****************************/
- //StaticObject Constraints
- /****************************/
- //No.1 From checklist
- //Check if the object is out of the field
- @Constraint(targetEditorId = "ca.mcgill.ecse.fairtracks.FairtracksDsl",
- severity = "error",
- message = "Object out of court",
- key = {o1})
- pattern outOfField(o1 : FTStaticObject) {
- find lowerBoundOfTrack(o1, low);
- find upperBoundOfTrack(o1, high);
- FTStaticObject.lengthX(o1, lengthx);
- FTStaticObject.lengthY(o1, lengthy);
- FTStaticObject.position.LLx(o1, llx);
- FTStaticObject.position.LLy(o1, lly);
- check( (llx < low) || (lly < low) || (llx + lengthx) > high || (lly + lengthy) > high);
- }
- /****************************/
- //Player Constraints
- /****************************/
- //No.2 from checklist
- //Player has to start from one of the starting corner
- @Constraint(targetEditorId = "ca.mcgill.ecse.fairtracks.FairtracksDsl",
- severity = "error",
- message = "Player does not start at correct location",
- key = {player1})
- pattern incorrectStartPlayer(player1 : FTPlayer){
- neg find startingPositionPlayer(player1);
- }
- //Helper pattern to see if player has the correct starting position
- private pattern startingPositionPlayer(player1 : FTPlayer){
- find lowerBoundOfTrack(player1, low);
- find upperBoundOfTrack(player1, high);
- FTPlayer.position.LLx(player1, llx);
- FTPlayer.position.LLy(player1, lly);
- check((llx == low && lly == low) || (llx == high && lly == low) || (llx == high && lly == high) || (llx == low && lly == high));
- }
- //No.3 from checklist
- //Check if two player has the same role
- @Constraint(targetEditorId = "ca.mcgill.ecse.fairtracks.FairtracksDsl",
- severity = "error",
- message = "duplicate role",
- key = {player1, player2})
- pattern duplicatePlayerRole(player1 : FTPlayer, player2 : FTPlayer, commonRole : FTRole) {
- FTPlayer.role(player1, commonRole);
- FTPlayer.role(player2, commonRole);
- player1 != player2;
- }
- //No.4 from checklist
- //Must start from different position
- @Constraint(targetEditorId = "ca.mcgill.ecse.fairtracks.FairtracksDsl",
- severity = "error",
- message = "duplicate starting corner",
- key = {player1, player2})
- pattern duplicateStartPosition(player1 : FTPlayer, player2 : FTPlayer){
- FTPlayer.position.LLx(player1,samex);
- FTPlayer.position.LLx(player2,samex);
- FTPlayer.position.LLy(player1,samey);
- FTPlayer.position.LLy(player2,samey);
- player1 != player2;
- }
- //No.5 from checklist
- //To be discussed
- //No.6 from checklist
- //Player who can pickup has to have pickup color associated
- @Constraint(targetEditorId = "ca.mcgill.ecse.fairtracks.FairtracksDsl",
- severity = "error",
- message = "No Pickable Obstacle color",
- key = {player1})
- pattern noPickupColor(player1: FTPlayer){
- FTPlayer.canPickUpObject(player1, true);
- neg find playerByColor(player1);
- }
- //Helper pattern to check if player has any pickable color
- pattern playerByColor(p1 : FTPlayer){
- FTPlayer.pickUpColor.color(p1,::White);
- } or {
- FTPlayer.pickUpColor.color(p1,::Red);
- } or {
- FTPlayer.pickUpColor.color(p1,::Blue);
- } or {
- FTPlayer.pickUpColor.color(p1,::Yellow);
- }
- /****************************/
- //Zone Constraints
- /****************************/
- //No.7 from checklist
- //Removed from the new model
- //No.8 from checklist
- @Constraint(targetEditorId = "ca.mcgill.ecse.fairtracks.FairtracksDsl",
- severity = "error",
- message = "Incorrect containment shape",
- key = {zone1, zone2})
- pattern incorrectContainShape(zone1 : FTZone, zone2 : FTZone){
- FTZone.contains(zone1, zone2);
- FTZone.position.LLx(zone1, llx1);
- FTZone.position.LLy(zone1, lly1);
- FTZone.position.LLx(zone2, llx2);
- FTZone.position.LLy(zone2, lly2);
- FTZone.lengthX(zone1, lengthx1);
- FTZone.lengthY(zone1, lengthy1);
- FTZone.lengthX(zone2, lengthx2);
- FTZone.lengthY(zone2, lengthy2);
- check(llx1 > llx2 || lly1 > lly2 || (llx2 + lengthx2) > (llx1 + lengthx1) || (lly2 + lengthy2) > (lly1 + lengthy1) );
- }
- //No.9 from checklist
- //To be discussed
- //No.10 from checklist
- //TODO
- //No.11 from checklist
- //TODO
- //No.12 from checklist
- //To be discussed
- //No.13 from checklist
- //TODO To be discussed
- //EVERY ZONE NEEDS AN adj zone unless ziplined
- //pattern noAdjAllowedZone(zone1 : FTZone){
- // FTZone.disallowedPlayers(zone1, player1);
- // FTZone.isAdjacentTo(zone1, zone2);
- //}
- //
- //pattern disallowedZoneForPlayer(player1, zone1){
- // FTZone.disallowedPlayers(zone1,player1);
- //}
- //No.14 from checklist
- @Constraint(targetEditorId = "ca.mcgill.ecse.fairtracks.FairtracksDsl",
- severity = "error",
- message = "Circular Zone containment",
- key = {z1, z2})
- pattern circularZoneContainment(z1 : FTZone, z2 : FTZone){
- find contains(z2,z1);
- find contains+(z1,z2);
- z1 != z2;
- }
- //No.15 from checklist
- @Constraint(targetEditorId = "ca.mcgill.ecse.fairtracks.FairtracksDsl",
- severity = "error",
- message = "Self containment",
- key = {z1, z2})
- pattern noSelfContain(z1 : FTZone, z2 : FTZone){
- FTZone.contains(z1, z2);
- z1 == z2;
- }
- /****************************/
- //Obstacles Constraints
- /****************************/
- //No.23 from checklist with concrete value
- //@Constraint(targetEditorId = "org.eclipse.emf.ecore.presentation.ReflectiveEditorID",
- // severity = "error",
- // message = "The obs close to corner",
- // key = {o1})
- //pattern obstacleCloseToCorner(o1 : FTObstacle){
- // find lowerBoundOfTrack(o1, low);
- // FTObstacle.LLx(o1, llx1);
- // check(llx1 < low+2);
- //} or {
- // find lowerBoundOfTrack(o1, low);
- // FTObstacle.LLy(o1, lly1);
- // check(lly1 < low+2);
- //} or {
- // find upperBoundOfTrack(o1, high);
- // FTObstacle.URx(o1, urx1);
- // check(urx1 > high-2);
- //} or {
- // find upperBoundOfTrack(o1, high);
- // FTObstacle.URy(o1, ury1);
- // check(ury1 > high-2);
- //}
- //////////////////////////////
- //Zipline Constraints
- //////////////////////////////
- //No.24 from checklist
- pattern identicalPositionZipline(zipline : FTZipline) {
- FTZipline.lengthX(zipline, lengthx);
- FTZipline.lengthY(zipline, lengthy);
- check(lengthx == 0 && lengthy == 0);
- }
- /****************************/
- //Helper patterns
- /****************************/
- private pattern upperBoundOfTrack(o1 : FTStaticObject, high : java Integer ) {
- Fairtracksmodel.staticObjects(fairtrack,o1);
- Fairtracksmodel.boardUpperBound(fairtrack, high);
- }
- private pattern lowerBoundOfTrack(o1 : FTStaticObject, low : java Integer ) {
- Fairtracksmodel.staticObjects(fairtrack,o1);
- Fairtracksmodel.boardLowerBound(fairtrack, low);
- }
- private pattern contains(z1 : FTZone, z2 : FTZone){
- FTZone.contains(z1, z2);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement