示例#1
0
文件: ai.cpp 项目: rthoward/avast_cpp
bool PlayerAI::shouldStop(Actor *me) {
   TCODList<Actor *> actors = engine.getActorList();

   // check if any potential attackers entered FOV
   for (Actor **iter = actors.begin(); iter != actors.end(); iter++) {
      Actor *actor = *iter;
      if (actor == NULL)                     continue;
      if (actor == me)                       continue;
      if ( !(actor->getAttacker()) )         continue;
      if (actor->isDead())                   continue;
      if (engine.getMap()->isInFov(actor->getX(), actor->getY()))
         return true;
   }

   int x = me->getX(), y = me->getY();
   Map *map = engine.getMap();

   // check if next tile is obstructed
   switch (aiState) {
      case AUTORUN_LEFT    : return !(map->canWalk(x - 1, y)); break;
      case AUTORUN_RIGHT   : return !(map->canWalk(x + 1, y)); break;
      case AUTORUN_UP      : return !(map->canWalk(x, y - 1)); break;
      case AUTORUN_DOWN    : return !(map->canWalk(x, y + 1)); break;
      default              : return false;
   }
}
示例#2
0
文件: ai.cpp 项目: rthoward/avast_cpp
Actor *PlayerAI::chooseFromInventory(Actor *me, string filter) {
   static const int INV_WIDTH = 50;
   static const int INV_HEIGHT = 28;
   static TCODConsole con(INV_WIDTH, INV_HEIGHT);
   string title = "";

   // determine title of menu based on filter type. defaults to "inventory"
   if (filter == "")
      title = "inventory";
   else
      title = filter;

   con.setDefaultForeground(TCODColor(200, 180, 50));
   con.printFrame(0, 0, INV_WIDTH, INV_HEIGHT, true, TCOD_BKGND_DEFAULT,
         title.c_str());
   con.setDefaultForeground(TCODColor::white);
   int shortcut = 'a';
   int y = 1;

   TCODList<Actor *> inventory = me->getContainer()->getInventory();
   Actor *item;

   for (Actor **iter = inventory.begin(); iter != inventory.end(); iter++) {
      item = *iter;
      
      if (item == NULL)       continue;

      // apply necessary filters
      if (filter == "equipment") {
         if (!item->isEquipment())
            continue;
      } else if (filter == "equipped") {
         if (!me->getEquipment()->isEquipped(me, item))
            continue;
      }

      string itemName = item->getName();
      if (me->getEquipment()->isEquipped(me, item))
         itemName += " [equipped]";
      con.print(2, y, "(%c) - %s", shortcut, itemName.c_str());
      y++;
      shortcut++;
   }

   TCODConsole::blit(&con, 0, 0, INV_WIDTH, INV_HEIGHT, TCODConsole::root,
         engine.getScreenWidth() / 2 - INV_WIDTH / 2,
         engine.getScreenHeight() / 2 - INV_HEIGHT / 2);
   TCODConsole::flush();

   TCOD_key_t key;
   TCODSystem::waitForEvent(TCOD_EVENT_KEY_PRESS, &key, NULL, true);

   if (key.vk == TCODK_CHAR) {
      int itemIndex = key.c - 'a';
      if (itemIndex >= 0 && itemIndex < inventory.size())
         return inventory.get(itemIndex);
   }

   return NULL;
}
示例#3
0
// export to HTML
void genDoc() {		
	// generates the doc for each page
	for (PageData **it=pages.begin();it!=pages.end();it++) {
		printf ("Generating %s - %s...\n",(*it)->pageNum,(*it)->title);
		genPageDocFromTemplate(*it);
	}
	genPageDocFromTemplate(root);
}
示例#4
0
// return the subpage # kidNum
PageData *getKidByNum(PageData *father, int kidNum) {
	for (PageData **it=pages.begin(); it != pages.end(); it++) {
		if ( (*it)->father == father && (*it)->order == kidNum ) {
			return *it;
		}
	}
	return NULL;
}
示例#5
0
//
// Retourne la liste des items fixes dans le fov du joueur
//
TCODList<EntityFixedItem*> Level::getFixedItemsInFov()
{
    TCODList<EntityFixedItem*> result;

    for (EntityFixedItem* itemFixed: fixedItems_)
    {
        if (isInFov(itemFixed->x, itemFixed->y))
            result.push(itemFixed);
    }

    return result;
}
示例#6
0
//
// Retourne une liste de pointeurs des items d'une case px, py
//
TCODList<EntityItem*> Level::getItemsFromTile(const int& px, const int& py)
{
    TCODList<EntityItem*> result;

    for (EntityItem *item: items_)
    {
        if (item->x == px && item->y == py)
            result.push(item);
    }

    return result;
}
示例#7
0
// generate the color table from parsed colors
void printColorTable(FILE *f) {
	fprintf(f,"<table class=\"color\">\n");
	bool needHeader=true;
	int categ=0;
	for ( Color *col=colors.begin(); col!=colors.end(); col++) {
		if ( col->category ) {
			// a color category
			fprintf(f,"<tr><td></td><th colspan=\"8\">%s</th></tr>\n",col->name);
			needHeader=true;
			categ++;
		} else if ( categ == 1 ){
			// computed colors
			if ( needHeader ) fprintf(f,"<tr><td></td><td>desaturated</td><td>lightest</td><td>lighter</td><td>light</td><td>normal</td><td>dark</td><td>darker</td><td>darkest</td></tr>\n");
			needHeader=false;
			fprintf(f,"<tr><td>%s</td>",col->name);
			for (int cm =0; cm < NB_COLOR_MOD; cm++ ) {
				if ( colorModifiers[cm].name[0] != 0 ) col->name[0]=toupper(col->name[0]);
				float h,s,v;
				col->col.getHSV(&h,&s,&v);
				s *= colorModifiers[cm].satCoef;
				v *= colorModifiers[cm].valCoef;
				TCODColor modcol;
				modcol.setHSV(h,s,v);
				fprintf(f,"<td title=\"%s%s: %d,%d,%d\" style=\"background-color: rgb(%d,%d,%d)\"></td>",
					colorModifiers[cm].name,col->name,modcol.r,modcol.g,modcol.b,
					modcol.r,modcol.g,modcol.b);
				col->name[0]=tolower(col->name[0]);	
			}
			fprintf(f,"</tr>\n");
		} else if (strcmp(col->name,"grey")==0 ) {
			// grey colors
			fprintf(f,"<tr><td colspan=\"2\">&nbsp;</td><td>lightest</td><td>lighter</td><td>light</td><td>normal</td><td>dark</td><td>darker</td><td>darkest</td></tr>\n");
			fprintf(f,"<tr><td>grey</td><td>&nbsp;</td><td title=\"lightestGrey: 223,223,223\" style=\"background-color: rgb(223, 223, 223);\"></td><td title=\"lighterGrey: 191,191,191\" style=\"background-color: rgb(191, 191, 191);\"></td><td title=\"lightGrey: 159,159,159\" style=\"background-color: rgb(159, 159, 159);\"></td><td title=\"grey: 127,127,127\" style=\"background-color: rgb(127, 127, 127);\"></td><td title=\"darkGrey: 95,95,95\" style=\"background-color: rgb(95, 95, 95);\"></td><td title=\"darkerGrey: 63,63,63\" style=\"background-color: rgb(63, 63, 63);\"></td><td title=\"darkestGrey: 31,31,31\" style=\"background-color: rgb(31, 31, 31);\"></td></tr>\n");
		} else if ( strcmp(col->name,"sepia") == 0 ) {
			// sepia colors
			fprintf(f,"<tr><td>sepia</td><td>&nbsp;</td><td title=\"lightestSepia: 222,211,195\" style=\"background-color: rgb(222, 211, 195);\"></td><td title=\"lighterSepia: 191,171,143\" style=\"background-color: rgb(191, 171, 143);\"></td><td title=\"lightSepia: 158,134,100\" style=\"background-color: rgb(158, 134, 100);\"></td><td title=\"sepia: 127,101,63\" style=\"background-color: rgb(127, 101, 63);\"></td><td title=\"darkSepia: 94,75,47\" style=\"background-color: rgb(94, 75, 47);\"></td><td title=\"darkerSepia: 63,50,31\" style=\"background-color: rgb(63, 50, 31);\"></td><td title=\"darkestSepia: 31,24,15\" style=\"background-color: rgb(31, 24, 15);\"></td></tr>");
		} else {
			// miscellaneous colors
			fprintf(f,"<tr><td>%s</td><td title=\"%s: %d,%d,%d\" style=\"background-color: rgb(%d,%d,%d)\"></td></tr>\n",
				col->name,
				col->name,col->col.r,col->col.g,col->col.b,
				col->col.r,col->col.g,col->col.b);
		}
	}
	fprintf(f,"</table>");
}
示例#8
0
bool Pickable::use(Actor *owner, Actor *wearer) {
    TCODList<Actor *> list;
    if (selector) {
        selector->selectTargets(wearer, list);
    }

    bool succeed = false;
    for (Actor **it = list.begin(); it != list.end(); it++) {
        if (effect->applyTo(*it)) {
            succeed = true;
        }
    }

    if (succeed) {
        if (wearer->container) {
            wearer->container->remove(owner);
            delete owner;
        }
    }

    return succeed;
}
示例#9
0
bool TCODBsp::traverseLevelOrder(ITCODBspCallback *listener, void *userData) {
	TCODList<TCODBsp *> stack;
	stack.push(this);
	while ( ! stack.isEmpty() ) {
		TCODBsp *node=stack.get(0);
		stack.remove(node);
		if ( node->getLeft() ) stack.push(node->getLeft());
		if ( node->getRight() ) stack.push(node->getRight());
		if (!listener->visitNode(node,userData)) return false;
	}
	return true;
}
示例#10
0
void DamagingAura::apply(Actor *target){
	TCODRandom *rng = TCODRandom::getInstance();
	int realDamage = rng->getInt(bonus*0.8,bonus*1.25);

	TCODList<Actor *> inRadius;
	if (!smart){
		engine.getAllActorsInRadius(inRadius,target->x, target->y, radius);
	} else {
		engine.getAllActorsInRadius(inRadius,target->x, target->y, radius, SpellCastingConstants::ENEMY, target->hostile);
	}

	if (!inRadius.isEmpty()){

		for (Actor **iter = inRadius.begin();
			iter != inRadius.end(); iter++) {
			Actor *act1 = *iter;

			if (act1->destructible) act1->destructible->takeDamage(act1, target, realDamage);
		}
	}

	inRadius.clearAndDelete();
}
bool Pickable::use(Actor *owner, Actor *wearer){
    bool succeed = false;
    if(!effect){
        engine.gui->message(TCODColor::lightGrey, "This item does nothing");
        return false;
    }

    if(effect->targetType == Effect::ACTOR){
        TCODList<Actor *> list;
        if(selector){
            selector->selectTargets(wearer, list);
        }else{
            list.push(wearer);
        }
        for(Actor **it = list.begin(); it != list.end(); it++){
            if(effect->applyTo(*it)){
                succeed = true;
            }
        }
    }else if(effect->targetType == Effect::POSITION){
        int x,y;
        printf("%d, %d", x, y);
        if(selector){
            if(selector->selectPosition(x,y)){
                if(effect->applyTo(x,y))
                    succeed = true;
            }
        }
    }
    if(succeed){
        if(wearer->container){
            wearer->container->remove(owner);
            delete owner;
        }
    }
    return succeed;
}
示例#12
0
// computes the page tree and auto-numbers pages
void buildTree() {
	// get the list of root (level 0) pages
	TCODList<PageData *>rootPages;
	for (PageData **it=pages.begin();it!=pages.end();it++) {
		// page requires at least a @PageName and @PageTitle
		if (! (*it)->name ) {
			printf ("ERROR : page #%d (%s) in %s has no @PageName\n",
				(*it)->fileOrder,(*it)->name ? (*it)->name : "null", (*it)->filename);
			it=pages.remove(it);
			continue;
		}
		if (! (*it)->title ) {
			printf ("ERROR : page #%d (%s) in %s has no @PageTitle\n",
				(*it)->fileOrder,(*it)->name ? (*it)->name : "null",(*it)->filename);
			it=pages.remove(it);
			continue;
		}
		if ( (*it)->fatherName == NULL ) rootPages.push(*it);
	}
	// first, order the level 0 pages according to their category
	int categId=0;
	while ( categs[categId] ) {	
		for (PageData **it=pages.begin();it!=pages.end();it++) {
			if ( (*it)->fatherName == NULL && strcmp((*it)->categoryName,categs[categId]) == 0 ) {
				// new root page
				root->numKids++;
				(*it)->father=root;
				(*it)->order=root->numKids;
				char tmp[1024];
				sprintf(tmp,"%d",(*it)->order);
				(*it)->pageNum=strdup(tmp);
				sprintf(tmp,"doc/html2/%s.html",(*it)->name);
				(*it)->url=strdup(tmp);
				sprintf(tmp,"<a onclick=\"link('../index2.html')\">Index</a> &gt; <a onclick=\"link('%s.html')\">%s. %s</a>",
					(*it)->name,(*it)->pageNum,(*it)->title);
				(*it)->breadCrumb=strdup(tmp);						
				rootPages.remove(*it);
			}
		}
		categId++;
	}
	// pages with unknown categories
	for ( PageData **it=rootPages.begin(); it != rootPages.end(); it++) {
		printf ("ERROR : unknown category '%s' in page '%s'\n",(*it)->categoryName,(*it)->name);
		pages.remove(*it);
	}
	// build the subpages tree
	for (PageData **it=pages.begin();it!=pages.end();it++) {
		if ( (*it)->fatherName != NULL ) {
			// sub-page. find its daddy and order
			(*it)->father=getPage((*it)->fatherName);
			if ( ! (*it)->father ) {
				printf ("ERROR : unknown father '%s' for page '%s'\n",
					(*it)->fatherName,(*it)->name);
				it=pages.remove(it);
				continue;
			}
			(*it)->father->numKids++;
			(*it)->order=(*it)->father->numKids;
		}
	}
	// now compute sub-page numbers 
	TCODList<PageData *> hierarchy;
	bool missing=true;
	while ( missing ) {
		missing=false;
		for (PageData **it=pages.begin();it!=pages.end();it++) {
			if ((*it)->pageNum == NULL ) {
				PageData *page=*it;
				if ( page->father->pageNum == NULL ) {
					missing=true;
				} else {                
					char tmp[256];
					sprintf(tmp,"%s.%d", page->father->pageNum,page->order);
					page->pageNum = strdup(tmp);
					sprintf(tmp,"doc/html2/%s.html",page->name);
					page->url=strdup(tmp);
				}
			}
		}
	}
	// now compute prev/next links and breadcrumbs for sub pages
	for (PageData **it=pages.begin();it!=pages.end();it++) {
		PageData *page=*it;
		page->prev=getPrev(page);
		// prev link
		if ( page->prev ) {
			char tmp[1024];
			sprintf (tmp,
				"<a class=\"prev\" onclick=\"link('%s.html')\">%s. %s</a>",
				page->prev->name,page->prev->pageNum,page->prev->title);
			page->prevLink=strdup(tmp);
		}
		// next link
		page->next=getNext(page);
		if ( page->next ) {
			char tmp[1024];
			sprintf (tmp,
				"%s<a class=\"next\" onclick=\"link('%s.html')\">%s. %s</a>",
				page->prev ? "| " : "",
				page->next->name,page->next->pageNum,page->next->title);
			page->nextLink=strdup(tmp);
		}
		// breadCrumb
		if (! page->breadCrumb ) {
			char tmp[1024];
			TCODList<PageData *> hierarchy;
			PageData *curPage=page;
			while ( curPage ) {
				hierarchy.push(curPage);
				curPage=curPage->father;
			}
			char *ptr=tmp;
			ptr[0]=0;
			while ( ! hierarchy.isEmpty() ) {
				curPage=hierarchy.pop();
				if ( curPage == root ) {
					sprintf(ptr, "<a onclick=\"link('../%s.html')\">%s</a>", 
						curPage->name,curPage->title);
				} else {
					sprintf(ptr, " &gt; <a onclick=\"link('%s.html')\">%s. %s</a>", 
						curPage->name,curPage->pageNum,curPage->title);
				}
				ptr += strlen(ptr);
			}
			page->breadCrumb =strdup(tmp);
		}
	}
}
示例#13
0
// parse a .hpp file and generate corresponding PageData
void parseFile(char *filename) {
	printf ("INFO : parsing file %s\n",filename);
	char *buf=loadTextFile(filename);
    if ( ! buf ) return;

    // now scan javadocs
    int fileOrder=1;
    char *ptr = strstr(buf,"/**");
    while (ptr) {
    	char *end = strstr(ptr,"*/");
    	if ( end ) {
	    	// parse the javadoc
	    	*end=0;
	    	char *directive = strchr(ptr,'@');
	    	while ( directive ) {
	    		if ( startsWith(directive,"@PageName") ) {
	    			char *pageName=NULL;
	    			directive = getIdentifier(directive+sizeof("@PageName"),&pageName);
	    			curPage=getPage(pageName);
					curFunc=NULL;
	    			if(!curPage) {
						// non existing page. create a new one
						curPage=new PageData();
						pages.push(curPage);
						curPage->filename = strdup(filename);
						curPage->fileOrder=fileOrder++;
						curPage->name=pageName;
						curFunc=NULL;
					}
	    		} else if ( startsWith(directive,"@PageTitle") ) {
	    			directive = getLineEnd(directive+sizeof("@PageTitle"),&curPage->title);
	    		} else if ( startsWith(directive,"@PageDesc") ) {
	    			directive = getParagraph(directive+sizeof("@PageDesc"),&curPage->desc);
	    		} else if ( startsWith(directive,"@PageFather") ) {
	    			directive = getIdentifier(directive+sizeof("@PageFather"),&curPage->fatherName);
	    			if ( strcmp(curPage->fatherName,curPage->name) == 0 ) {
	    				printf ("ERROR : file %s : page %s is its own father\n", filename,
	    					curPage->name);
	    				exit(1);
	    			}
	    		} else if ( startsWith(directive,"@PageCategory") ) {
	    			directive = getLineEnd(directive+sizeof("@PageCategory"),&curPage->categoryName);
	    		} else if ( startsWith(directive,"@FuncTitle") ) {
					curFunc=new FuncData();
					curPage->funcs.push(curFunc);
	    			directive = getLineEnd(directive+sizeof("@FuncTitle"),&curFunc->title);
	    		} else if ( startsWith(directive,"@ColorTable") ) {
					directive += sizeof("@ColorTable");
					curPage->colorTable=true;
	    		} else if ( startsWith(directive,"@ColorCategory") ) {
					Color col;
					directive=getLineEnd(directive+sizeof("@ColorCategory"),&col.name);
					col.category=true;
					colors.push(col);
	    		} else if ( startsWith(directive,"@Color") ) {
					Color col;
					directive=getIdentifier(directive+sizeof("@Color"),&col.name);
					sscanf(directive,"%d,%d,%d",&col.col.r,&col.col.g,&col.col.b);
					colors.push(col);
					while (! isspace(*directive)) directive++;
	    		} else if ( startsWith(directive,"@FuncDesc") ) {
					if (! curFunc ) {
						curFunc=new FuncData();
						curPage->funcs.push(curFunc);
					}
	    			directive = getParagraph(directive+sizeof("@FuncDesc"),&curFunc->desc);
	    		} else if ( startsWith(directive,"@CppEx") ) {
					if (! curFunc ) {
						curFunc=new FuncData();
						curPage->funcs.push(curFunc);
					}
	    			directive = getCodeParagraph(directive+sizeof("@CppEx")-1,&curFunc->cppEx);
	    		} else if ( startsWith(directive,"@C#Ex") ) {
					if (! curFunc ) {
						curFunc=new FuncData();
						curPage->funcs.push(curFunc);
					}
	    			directive = getCodeParagraph(directive+sizeof("@C#Ex")-1,&curFunc->csEx);
	    		} else if ( startsWith(directive,"@CEx") ) {
					if (! curFunc ) {
						curFunc=new FuncData();
						curPage->funcs.push(curFunc);
					}
	    			directive = getCodeParagraph(directive+sizeof("@CEx")-1,&curFunc->cEx);
	    		} else if ( startsWith(directive,"@PyEx") ) {
					if (! curFunc ) {
						curFunc=new FuncData();
						curPage->funcs.push(curFunc);
					}
	    			directive = getCodeParagraph(directive+sizeof("@PyEx")-1,&curFunc->pyEx);
	    		} else if ( startsWith(directive,"@LuaEx") ) {
					if (! curFunc ) {
						curFunc=new FuncData();
						curPage->funcs.push(curFunc);
					}
	    			directive = getCodeParagraph(directive+sizeof("@LuaEx")-1,&curFunc->luaEx);
	    		} else if ( startsWith(directive,"@Cpp") ) {
					if (! curFunc ) {
						curFunc=new FuncData();
						curPage->funcs.push(curFunc);
					}
	    			directive = getCodeParagraph(directive+sizeof("@Cpp")-1,&curFunc->cpp);
	    		} else if ( startsWith(directive,"@C#") ) {
					if (! curFunc ) {
						curFunc=new FuncData();
						curPage->funcs.push(curFunc);
					}
	    			directive = getCodeParagraph(directive+sizeof("@C#")-1,&curFunc->cs);
	    		} else if ( startsWith(directive,"@C") ) {
					if (! curFunc ) {
						curFunc=new FuncData();
						curPage->funcs.push(curFunc);
					}
	    			directive = getCodeParagraph(directive+sizeof("@C")-1,&curFunc->c);
	    		} else if ( startsWith(directive,"@Py") ) {
					if (! curFunc ) {
						curFunc=new FuncData();
						curPage->funcs.push(curFunc);
					}
	    			directive = getCodeParagraph(directive+sizeof("@Py")-1,&curFunc->py);
	    		} else if ( startsWith(directive,"@Lua") ) {
					if (! curFunc ) {
						curFunc=new FuncData();
						curPage->funcs.push(curFunc);
					}
	    			directive = getCodeParagraph(directive+sizeof("@Lua")-1,&curFunc->lua);
	    		} else if ( startsWith(directive,"@Param") ) {
					ParamData *param=new ParamData();
					curFunc->params.push(param);
	    			directive = getIdentifier(directive+sizeof("@Param"),&param->name);
	    			directive = getParagraph(directive,&param->desc);
				} else {
					char *tmp;
					directive = getIdentifier(directive,&tmp);
					printf ("WARN unknown directive  '%s'\n",tmp);
					free(tmp);
				}
				directive = strchr(directive,'@');
			}
	    	ptr=strstr(end+2,"/**");
	    } else ptr=NULL;
	}
}
示例#14
0
// find the next page of same level (NULL if none)
PageData *getNext(PageData *page) {
	for (PageData **it=pages.begin();it!=pages.end();it++) {
		if ( (*it)->father == page->father && (*it)->order == page->order+1 ) return *it;
	}
	return NULL;	
}
示例#15
0
// get a page by its name or NULL if it doesn't exist
PageData *getPage(const char *name) {
	for (PageData **it=pages.begin();it!=pages.end();it++) {
		if (strcmp((*it)->name,name)==0) return *it;
	}
	return NULL;
}
示例#16
0
文件: list.hpp 项目: AMouri/Rouge
	/**
	@PageName list_list
	@FuncTitle Concatenating two lists
	@FuncDesc You can concatenate two lists. Every element of l2 will be added to current list (or l in the C version) :
	@Cpp template <class T> void TCODList::addAll(const TCODList &l2)
	@C void TCOD_list_add_all(TCOD_list_t l, TCOD_list_t l2)
	@Param l	The list inside which elements will be added.
	@Param l2	the list handler containing elements to insert.
	@CppEx 
		TCODList<int> intList;
		intList.set(1,3); // intList contains 2 elements : 0, 3
		TCODList<int> intList2; // intList2 is empty
		intList2.set(0,1); // intList2 contains 1 element : 1
		intList2.addAll(intList); // intList2 contains 3 elements : 1, 0, 3
	@CEx 
		TCOD_list_t intList = TCOD_list_new();
		TCOD_list_set(intList,1,(const void *)3);
		TCOD_list_t intList2 = TCOD_list_new();
		TCOD_list_set(intList2,0,(const void *)1);
		TCOD_list_add_all(intList2,intList);
	*/
	void addAll(const TCODList<T> &l2) {
		for (T *t=l2.begin(); t!= l2.end(); t++) {
			push(*t);
		}
	}
示例#17
0
void TargetSelector::selectTargets(Actor *wearer, TCODList<Actor *> &list) {
    switch (type) {
        case SELF:
        {
            list.push(wearer);
        }
        break;
        case CLOSEST_MONSTER:
        {
            Actor *closestMonster = engine.getClosestMonster(wearer->x, wearer->y, range);
            if (closestMonster) {
                list.push(closestMonster);
            }
        }
        break;
        case SELECTED_MONSTER:
        {
            int x, y;
            engine.gui->message(TCODColor::cyan, "Left-click to select an enemy,\nor right-click to cancel ");
            if (engine.pickATile(&x, &y, range)) {
                Actor *actor = engine.getActor(x, y);
                if (actor) {
                    list.push(actor);
                }
            }
        }
        break;
        case WEARER_RANGE:
        {
            for (Actor **iterator = engine.actors.begin();
                iterator != engine.actors.end(); iterator++) {
                Actor *actor = *iterator;
                if (actor != wearer && actor->destructible && !actor->destructible->isDead() &&
                    actor->getDistance(wearer->x, wearer->y) <= range) {
                    list.push(actor);
                }
            }
        }
        break;
        case SELECTED_RANGE:
        {
            int x, y;
            engine.gui->message(TCODColor::cyan, "Left-click to select an enemy,\nor right-click to cancel ");
            if (engine.pickATile(&x, &y)) {
                for (Actor **iterator = engine.actors.begin();
                     iterator != engine.actors.end(); iterator++) {
                    Actor *actor = *iterator;
                    if (actor->destructible && !actor->destructible->isDead() &&
                            actor->getDistance(x, y) <= range) {
                        list.push(actor);
                    }
                }
            }
        }
        break;
    }

    if (list.isEmpty()) {
        engine.gui->message(TCODColor::lightGrey, "No enemy is close enough");
    }
}