#include "squaredance.h"

char *orientationNames[] = {
    "fixed",
    "forward",
    "backward",
    "forward90",
    "forward-90",
    "rotating",
    "rotateto",
    "cw rotateto",
    "ccw rotateto",
    "faceDancer",
    NULL
};

char *commandNames[] = {
    "moveto",
    "pause",
    "lineto",
    "curveto",
    "if",
    "elseif",
    "else",
    "resetDance",
    "return",
    "end",
    "copy",
    "transform",
    NULL
};

char *conditionNames[] = {
    "always",
    "if topset",
    "if not topset",
    "if bottomset",
    "if not bottomset",
    "if semi topset",
    "if not semi topset",
    "if semi bottomset",
    "if not semi bottomset",
    "if not topset nor semi",
    "if not bottomset nor semi",
    "if not top nor bottomset",
    NULL
};

char *bandNames[] = {
    "unspecified",
    "left",
    "bottom",
    "right",
    "top",
    NULL
};

char sexChars[] = { 'm', 'f', 'l', 'c', 'r' };
char *sexNames[] = {
    "male",
    "female",
    "left",
    "center",
    "right",
    NULL
};

char *roleNames[] = {
    "1s",
    "2s",
    "3s",
    "4s",
    "5s",
    "6s",
    "7s",
    "8s",
    "9s",
    "10s",
    "11s",
    "12s",
    "13s",
    "14s",
    "15s",
    "16s",
    "17s",
    "18s",
    "19s",
    "20s",
    "21s",
    "22s",
    "23s",
    "24s",
    "25s",
    "26s",
    "27s",
    "28s",
    "29s",
    "30s",
    "1s left",		/* four face four */
    "1s right",
    "2s left",
    "2s right",
    "out at top",
    "out at bottom",
    "out at top 1 of 2",
    "out at top 2 of 2",
    "out bottom 1 of 2",
    "out bottom 2 of 2",
    "out at top 1 of 3",
    "out at top 2 of 3",
    "out at top 3 of 3",
    "out bottom 1 of 3",
    "out bottom 2 of 3",
    "out bottom 3 of 3",
    "out top left",	/* four face four */
    "out top right",
    "out bottom left",
    "out bottom right",
/*
    "top 1s",
    "top 2s",
    "top 3s",
    "bottom 1s",
    "bottom 2s",
    "bottom 3s",
*/
    "out at bottom.alt",
    "waiting",
    "1s.progression",	/* Used in scottish on the second time through the dance */
    "3s.progression",	/*  to get the 1s and 3s to switch places. Only for dances */
			/*  where we can't do it automagically (if the threes */
			/*  have something to do in the first few bars) */
    "4s.progression",	/* Used in scottish on the third time through if we */
			/*  couldn't swith the 1s+3s in 2nd iteration, then */
			/*  we must swith the 3s+4s at the start of the third */
			/*  (presumably the standard progression doesn't work)*/
			/*  will be used with 3s.progression (which has a */
			/*  different meaning when used with 4s than with 1s) */
    NULL
};

int role2couple[] = {
    1,
    2,
    3,
    4,
    5,
    6,
    7,
    8,
    9,
    10,
    11,
    12,
    13,
    14,
    15,
    16,
    17,
    18,
    19,
    20,
    21,
    22,
    23,
    24,
    25,
    26,
    27,
    28,
    29,
    30,
    1,		/* four face four */
    2,
    3,
    4,
    0,		/* out at top */
    0,		/* out at bottom */
    0,		/* out at top 1 of 2 */
    0,		/* out at top 2 of 2 */
    -1,		/* out at bottom 1 of 2 */
    -2,		/* out at bottom 2 of 2 */
    0,		/* out at top 1 of 3 */
    0,		/* out at top 2 of 3 */
    0,		/* out at top 3 of 3 */
    -1,		/* out at bottom 1 of 3 */
    -2,		/* out at bottom 2 of 3 */
    -3,		/* out at bottom 3 of 3 */
    0,		/* four face four out at top left */
    0,
    0,
    0,
    -1,		/* out bottom alt */
    -1,		/* waiting */
    1,		/* 1s progression (shouldn't get used) */
    3		/* 3s progression (shouldn't get used) */
};

char *becketStyle[] = {
    "none",
    "cw",
    "ccw",
    NULL
};

char *startFormationNames[] = {
    "Squared Set",
    "6 Couple Rectangle",
    "Facing Couples",
    "Facing Couples Becket",
    "Facing People",
    "Couple",
    "Singleton",
    "Right Hand Wave",
    "Left Hand Wave",
    "2 Right Hand Waves",
    "2 Left Hand Waves",
    "Duple Minor",
    "Becket",
    "Becket CCW",
    "Short Waves",
    "Duple Minor Progressed",
    "Three Face Three",
    "Four Face Four",
    "Tempest",
    "Quadruple Minor",
    "Quadruple Minor Becket",
    "Triple Minor",
    "2 Couple Longways",
    "3 Couple Longways",
    "4 Couple Longways",
    "5 Couple Longways",
    "6 Couple Longways",
    "7 Couple Longways",
    "8 Couple Longways",
    "3 Couple Circle",
    "5 Couple Circle",
    "6 Couple Circle",
    "7 Couple Circle",
    "Square of Trios",
    "Scottish 2 in 4",
    "Scottish 3 in 4",
    "Circular Monople",
    "Trio Circular Monople",
    "Rotated Triple Minor",
    "Custom",
    "Custom3",
    NULL
};

char *styleNames[] = {
    "English Country Dance",
    "Contredanse",
    "Old Scottish Country Dance",
    "American Country Dance",
    "Cotillion",
    "Quadrille",
    "Scottish Country Dance",
    "Square Dance",
    "Contra Dance",
    "Appalachian Circle Dance",
    "Longsword Dance",

    "Mine",
    NULL
};

char *substyleNames[] = {
    "traditional",
    "basic1",
    "basic2",
    "mainstream",
    "plus",
    "advanced1",
    "advanced2",
    "challenge1",
    "challenge2",
    "challenge3a",
    "challenge3b",
    NULL
};

char *difficultyLevelNames[] = {
    "Unspecified",
    "Very Easy",
    "Easy",
    "Easy/Intermediate",
    "Intermediate",
    "Intermediate/Hard",
    "Hard",
    "Very Hard",
    NULL
};

char *musicTypes[] = {
    "reel",
    "slip-jig",			/* Needs to come before jig, or both will be found as jigs */
    "jig",
    "strathspey",
    "medley",
    "waltz",
    "hornpipe",
    "march",
    "polka",
    "minuet",
    "gavotte",
    "galliard",
    "polonaiase",
    NULL
};

char *musicTypesShort[] = {
    "R",
    "SJ",			/* Needs to come before jig, or both will be found as jigs */
    "J",
    "S",
    "M",
    "W",
    "H",
    "MCH",
    "P",
    "MIN",
    "GAV",
    "GAL",
    "P",
    NULL
};

char *libNames[]= {
    "basic1.figure",
    "basic2.figure",
    "mainstream.figure",
    "plus.figure",
    "advanced1.figure",
    "advanced2.figure",
    "challenge1.figure",
    "challenge2.figure",
    "challenge3a.figure",
    "challenge3b.figure",
    "contra.figure",
    "ecd.figure",
    "scd.figure",
    NULL
};

int danceMatchEnum(char **list,char *instance) {
    int i;

    for ( i=0; list[i]!=NULL; ++i )
	if ( strcasecmp(list[i],instance)==0 )
return( i );

return( -1 );
}

struct maskMap handMaskMap[] = {
    { "right", HAND_RIGHT_MASK },
    { "left", HAND_LEFT_MASK },
    { "above", HAND_ABOVE_MASK },
    { "front", HAND_FRONT_MASK },
    { "back", HAND_BACK_MASK },
    { "ballroom", HAND_BALLROOM_MASK },
    { "out", HAND_OUT_MASK },
    { "notout", HAND_NOTOUT_MASK },
    { NULL }
};

struct maskMap tagNames[] = {
    { "USA", 0x1 },
    { NULL }
};
/* Standard tags */
/*
    USA
    sicilian
    as many as will
    circle
    hex
    mixer
    males progress
    women progress
    jig
    reel
    waltz
    strathspey
    visiting couple
    visiting man
    visiting woman
    visiting separate
    active couple	!doesn't visit, but only one couple active at a time
    heads/sides
    symmetrical
    DP/DP
    patter
    published by
    interesting
    do-si

    playford assembly
    playford ball
    cracking chestnuts
    Netherfield
*/

unsigned int danceMatchMask(struct maskMap *map, char *instance) {
    int i;

    for ( i=0; map[i].name!=NULL; ++i )
	if ( strcasecmp(map[i].name,instance)==0 )
return( map[i].mask );

return( 0 );
}

unsigned int danceRoleList(char **list, char *instance) {
    int i;
    char *pt, *end;
    unsigned int mask = 0;

    pt = instance;
    while ( (end=strchr(pt,','))!=NULL ) {
	for ( i=0; list[i]!=NULL; ++i ) {
	    if ( strlen(list[i])==end-pt && strncasecmp(pt,list[i],end-pt)==0 ) {
		mask |= (1<<i);
	break;
	    }
	}
	if ( list[i]==NULL )
return( 0xffffffff );
	pt = end+1;
    }
    if ( *pt=='\0' )
return( mask );

    for ( i=0; list[i]!=NULL; ++i ) {
	if ( strcasecmp(pt,list[i])==0 ) {
	    mask |= (1<<i);
return( mask );
	}
    }
return( 0xffffffff );
}
