local kingdoms, communes and signorie, the firm Aragonese (later Spanish) rule, the introduction of a sterile feudalism, as well as the discovery of the Americas, provoked an unstoppable decline of the Kingdom of Sardinia. A short period of uprisings occurred under the local noble Leonardo Alagon, marquess of Oristano, who defended his territories against Viceroy Nicolò Carroz and managed to defeat the viceroy's army in the 1470s, but was later crushed at the Battle of Macomer in 1478, ending any further revolts in the island. The unceasing attacks from north African pirates and a series of plagues (in 1582, 1652 and 1655) further worsened the situation. Aragonese conquest of Sardinia Although the "Kingdom of Sardinia and Corsica" could be said to have started as a questionable and extraordinary de jure state in 1297, its de facto existence began in 1324 when, called by their allies of the Judicate of Arborea in the course of war with the Republic of Pisa, James II seized the Pisan territories in the former states of Cagliari and Gallura and asserted his papally-approved title. In 1347; Aragon made war on landlords of the Doria House and the Malaspina House, who were citizens of the Republic of Genoa, which controlled most of the lands of the former Logudoro state in north-western Sardinia, including the city of Alghero and the semiautonomous Republic of Sassari, and added them to its direct domains. The Judicate of Arborea, the only Sardinian state that remained independent of foreign domination, proved far more difficult to subdue. Threatened by the Aragonese claims of suzerainty and consolidation of the rest of the island, in 1353 Arborea, under the leadership of Marianus IV, started the conquest of the remaining Sardinian territories, which formed the Kingdom of Sardinia. In 1368 an Arborean offensive succeeded in nearly driving the Aragonese from the island, reducing the "Kingdom of Sardinia and Corsica" to just the port cities of Cagliari and Alghero and incorporating everything else into their own kingdom. A peace treaty returned the Aragonese their previous possessions in 1388, but tensions continued and, in 1382, the Arborean army led by Brancaleone Doria again swept the most of the island into Arborean rule. This situation lasted until 1409 when the army of the Judicate of Arborea suffered a heavy defeat by the Aragonese army in the Battle of Sanluri. After the sale of the remaining territories for 100,000 gold