All Downloads are FREE. Search and download functionalities are using the official Maven repository.

stexceed.WarframeMarKT.1.0.1.source-code.main.kt Maven / Gradle / Ivy

import enums.AuctionType
import enums.OrderType
import enums.RivenAttribute
import enums.Status
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.supervisorScope
import payload.request.AuctionSearch
import payload.request.OrderUpdate
import payload.request.SigninCredentials
import payload.response.Items

suspend fun main() {
	print("logging in...")
	val profile = WarframeMarket.v1.auth.signIn(
		SigninCredentials(
			"[email protected]",
			"hbdfEcQ#Xu4o^#y@7TA@@F!ZE2#BaTS2kdiccrxW"
		)
	)
	println("done")

	print("requesting itemList...")
	val allItems = WarframeMarket.v1.items.get().items
	println("done")

	findRiven()
	supervisorScope {
		launch {
			while (false) {
				undercut(allItems.find { it.url_name == "magus_vigor" }!!, 39, 60, 5)
				undercut(allItems.find { it.url_name == "magus_husk" }!!, 75, 100, 5)
				undercut(allItems.find { it.url_name == "hunter_munitions" }!!, 9, 25, null)
				undercut(allItems.find { it.url_name == "nano_applicator" }!!, 70, 100, null)
				println("\n10s delay\n")
				delay(10000)
			}
		}
	}


}

suspend fun undercut(item: Items.Item, minimum: Int, maximum: Int, modRank: Int?) {
	print(item.item_name + ": ")

	val orders = WarframeMarket.v1.items.ITEM(item.url_name).orders.get().orders.filter {
		it.order_type == OrderType.sell &&
				it.user!!.status == Status.ingame &&
				setOf(null, it.mod_rank).contains(modRank)
	}

	val myOrder = orders.find {
		it.user!!.ingame_name == "LastExceed"
	} ?: run {
		println("not found")
		return
	}

	print("" + myOrder.platinum + " ")

	val topCompetitor = orders.filter {
		it != myOrder && it.platinum in minimum..maximum
	}.minWith(Comparator { p1, p2 ->
		p1.platinum.compareTo(p2.platinum).let {
			if (it == 0) {
				p1.last_update.compareTo(p2.last_update)
			} else {
				it
			}
		}
	})

	//////////

	val newPrice = when {
		topCompetitor == null
		-> if (myOrder.platinum != maximum) maximum else null

		topCompetitor.platinum == myOrder.platinum && topCompetitor.last_update < myOrder.last_update
		-> null

		else
		-> topCompetitor.platinum
	}

	if (newPrice == null) {
		println("unchanged")
		return
	}
	println("-> $newPrice")
	WarframeMarket.v1.profile.orders.ORDER(myOrder.id).update(
		OrderUpdate(
			myOrder.id,
			true,
			newPrice,
			myOrder.quantity,
			myOrder.mod_rank
		)
	)
}

suspend fun findRiven() {
	val auctions = WarframeMarket.v1.auctions.search.get(
		AuctionSearch(
			AuctionType.riven,
			"vectis",
			listOf(RivenAttribute.critical_chance, RivenAttribute.toxin_damage),
			null,
			null,
			null,
			null,
			null,
			null,
			null,
			null,
			null
		)
	).auctions

	val requiredPositives = listOf(
		RivenAttribute.critical_damage,
		RivenAttribute.base_damage_OR_melee_damage
	)
	val allowedNegatives = listOf(
		RivenAttribute.fire_rate_OR_attack_speed,
		RivenAttribute.magazine_capacity,
		RivenAttribute.ammo_maximum,
		RivenAttribute.projectile_speed,

		RivenAttribute.status_chance,
		RivenAttribute.status_duration,
		RivenAttribute.zoom
	)
	val filtered = auctions.filter { auction ->
		val hasRequiredPositive = auction.item.attributes.any { attribute ->
			attribute.positive && requiredPositives.contains(attribute.url_name)
		}
		val hasAllowedNegative = auction.item.attributes.any { attribute ->
			!attribute.positive && allowedNegatives.contains(attribute.url_name)
		}
		hasRequiredPositive && hasAllowedNegative
	}

	println(">>>>>>>" + filtered.size + "<<<<<<<")
}
//TODO:
//implement include
//check if kotlin 1.4 fixes type erasure
//getting reviews without auth breaks because for some reason it includes the personal profile which is full of nulls when not logged in
//package structure
//publish




© 2015 - 2025 Weber Informatics LLC | Privacy Policy