public void useManaPotion() { boolean b = false; for (int i = 0; i < 6; i++) { for (int j = 0; j < 5; j++) { if (inventory.itemAt(i, j) != null && inventory.itemAt(i, j).itemID == 6) { inventory.setItem(i, j, null); healMana((int) (80 + maxMana * 0.2)); break; } } if (b) break; } }
public void useItem(int y, int x) { // uses an item Item temp = inventory.itemAt(x, y); if (temp == null) return; else if (temp.itemID < 5) { // equips equipnent inventory.setItem(x, y, equipment.itemAt(0, temp.itemID)); equipment.setItem(0, temp.itemID, temp); calculateStats(); // recalculates player stats } else if (temp.itemID == 5) { // uses health potion inventory.setItem(x, y, null); healHealth((int) (80 + maxHealth * 0.2)); } else if (temp.itemID == 6) { // uses mana potion inventory.setItem(x, y, null); healMana((int) (80 + maxMana * 0.2)); } }
@Test public void bookFilePathWithSeriesInItWillReturnBookWithSeriesInItsName() throws Exception { String author = "Лукьяненко Сергей"; String bookName = "Лукьяненко 3 Калеки"; String seriesName = "Геном"; final String fileName = bookName + ".fb2.zip"; final String path = PathUtils.createPath("ru", "Л", author, seriesName, fileName); mockery.checking( new Expectations() { { allowing(fs).exists(path); will(returnValue(true)); allowing(fs).isDirectory(path); will(returnValue(false)); allowing(fs).getName(path); will(returnValue(fileName)); } }); Book item = (Book) extractor.get(path); assertThat(item.name, hasWords(seriesName)); }
@Test public void underscoreFolderPathReturnsFolder() throws Exception { final String folderName = "_scifi"; final String path = PathUtils.createPath("ru", "_", folderName); mockery.checking( new Expectations() { { allowing(fs).exists(path); will(returnValue(true)); allowing(fs).isDirectory(path); will(returnValue(true)); allowing(fs).getName(path); will(returnValue(folderName)); } }); Folder item = (Folder) extractor.get(path); assertThat(item, equalTo(new Folder(path, folderName))); }
@Test public void authorFolderPathReturnsAuthorObjectWithProperName() throws Exception { final String author = "Лукьяненко Сергей"; final String path = PathUtils.createPath("ru", "Л", author); mockery.checking( new Expectations() { { allowing(fs).exists(path); will(returnValue(true)); allowing(fs).isDirectory(path); will(returnValue(true)); allowing(fs).getName(path); will(returnValue(author)); } }); Author item = (Author) extractor.get(path); assertThat(item, equalTo(new Author(path, author))); }
@Test public void bookFilePathReturnsBookItemWithProperName() throws Exception { String author = "Лукьяненко Сергей"; String bookName = "Геном"; final String fileName = bookName + ".fb2.zip"; final String path = PathUtils.createPath("ru", "Л", author, fileName); mockery.checking( new Expectations() { { allowing(fs).exists(path); will(returnValue(true)); allowing(fs).isDirectory(path); will(returnValue(false)); allowing(fs).getName(path); will(returnValue(fileName)); } }); Book item = (Book) extractor.get(path); assertThat(item, equalTo(new Book(path, bookName))); }